From 89d23d33b3803c7de1f522f25ca90d652416cd0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Wed, 25 Feb 2015 14:32:44 +0100 Subject: [PATCH 1/4] Removed tests from regressions. --- bender.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/bender.js b/bender.js index aa7d55c9bce..8b07e0ce2f0 100644 --- a/bender.js +++ b/bender.js @@ -57,10 +57,7 @@ var config = { 'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace #9': 'env.safari', 'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #2': 'env.safari', 'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #3': 'env.safari', - 'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #8': 'env.safari', - - // IE8-10 (#12964) - 'tests/core/editable/getextractselectedhtml#test extractHtmlFromRange: tables #20': 'env.ie && env.version < 11' + 'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #8': 'env.safari' } }, From 60d34de43df0cea23c17b732bfb933959811ed59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Thu, 26 Feb 2015 12:00:10 +0100 Subject: [PATCH 2/4] Prevent from handling each node boundary more than once. --- core/editable.js | 17 +++++++++- .../core/editable/getextracthtmlfromrange.js | 31 +++++++++++++------ 2 files changed, 38 insertions(+), 10 deletions(-) diff --git a/core/editable.js b/core/editable.js index 483e4933a4c..e25cc77e5fe 100644 --- a/core/editable.js +++ b/core/editable.js @@ -2735,9 +2735,21 @@ editableRange, walker = new CKEDITOR.dom.walker( range ), startCell = range.startPath().contains( tableEditable ), - endCell = range.endPath().contains( tableEditable ); + endCell = range.endPath().contains( tableEditable ), + database = {}; walker.guard = function( node, leaving ) { + // Guard may be executed on some node boundaries multiple times, + // what results in creating more than one range for each selected cell. (#12964) + if ( node.type == CKEDITOR.NODE_ELEMENT ) { + var key = 'visited_' + ( leaving ? 'out' : 'in' ); + if ( node.getCustomData( key ) ) { + return; + } + + CKEDITOR.dom.element.setMarker( database, node, key, 1 ); + } + // Handle partial selection in a cell in which the range starts: //

x{xx

... // will store: @@ -2771,6 +2783,9 @@ walker.lastForward(); + // Clear all markers so next extraction will not be affected by this one. + CKEDITOR.dom.element.clearAllMarkers( database ); + return contentsRanges; function checkRemoveCellContents( node ) { diff --git a/tests/core/editable/getextracthtmlfromrange.js b/tests/core/editable/getextracthtmlfromrange.js index d83456b0b96..e3de3f751bc 100644 --- a/tests/core/editable/getextracthtmlfromrange.js +++ b/tests/core/editable/getextracthtmlfromrange.js @@ -24,15 +24,6 @@ getWithHtml = bender.tools.range.getWithHtml, img_src = '%BASE_PATH%_assets/img.gif'; - var tests = { - init: function() { - this.editables = {}; - - for ( var e in this.editors ) - this.editables[ e ] = this.editors[ e ].editable(); - } - }; - // // var playground = CKEDITOR.document.createElement( 'dl' ); // playground.on( 'paste', function( e ) { @@ -110,6 +101,28 @@ // output HTML | @ | like compareInnerHtml (accept) | like compareInnerHtml (we use it for uncertain cases) // | @! | like compareInnerHtml (expect) | like compareInnerHtml (we use it for empty blocks) + var tests = { + init: function() { + this.editables = {}; + + for ( var e in this.editors ) + this.editables[ e ] = this.editors[ e ].editable(); + }, + + 'test node markers are cleared': function() { + var html = decodeInputFillers( '
a{bc}d
' ), + expected = '
bc
', + editable = this.editables.inline, + range = setWithHtml( editable, html ); + + var docFragment = editable.extractHtmlFromRange( range ); + + assert.isInnerHtmlMatching( expected, docFragment.getHtml(), compareInnerHtmlOptions, 'Selected HTML' ); + assert.isNull( editable.findOne( 'tr' ).getChild( 0 ).getCustomData( 'visited_out' ), '1st cell should not have a marker' ); + assert.isNull( editable.findOne( 'tr' ).getChild( 1 ).getCustomData( 'visited_in' ), '2nd cell should not have a marker' ); + } + }; + addTests( { 'block': [ [ '

{a}

', 'a', '

[]@!

' ], From 9927b1135e7634ff6515b7bfb15053eec2749167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotrek=20Koszuli=C5=84ski?= Date: Thu, 26 Feb 2015 12:31:03 +0100 Subject: [PATCH 3/4] PrepareInnerHtmlForComparison should remove expando attributes. --- tests/_benderjs/ckeditor/static/tools.js | 5 +++++ tests/utils/html/compareinnerhtml.js | 10 ++++++++++ 2 files changed, 15 insertions(+) diff --git a/tests/_benderjs/ckeditor/static/tools.js b/tests/_benderjs/ckeditor/static/tools.js index 594e1675239..d494551a9d6 100644 --- a/tests/_benderjs/ckeditor/static/tools.js +++ b/tests/_benderjs/ckeditor/static/tools.js @@ -1442,6 +1442,11 @@ fixZWS = ( 'fixZWS' in options ) ? options.fixZWS : true, fixNbsp = ( 'fixNbsp' in options ) ? options.fixNbsp : true; + // On IE8- we need to get rid of expando attributes. + if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) { + innerHtml = innerHtml.replace( / data-cke-expando="[^"]*"/g, '' ); + } + if ( options.compareSelection ) { innerHtml = innerHtml.replace( selectionMarkers, '' ); } diff --git a/tests/utils/html/compareinnerhtml.js b/tests/utils/html/compareinnerhtml.js index f50b823fc80..6d9e6fefe2c 100644 --- a/tests/utils/html/compareinnerhtml.js +++ b/tests/utils/html/compareinnerhtml.js @@ -154,6 +154,16 @@ htmlTools.compareInnerHtml( 'a', 'a', opts ); assert.areSame( strOpts, JSON.stringify( opts ), 'options object has not been modified' ); + }, + + 'test on IE8 expando attributes are removed': function() { + if ( !CKEDITOR.env.ie || CKEDITOR.env.version > 8 ) { + assert.ignore(); + } + + assert.isTrue( htmlTools.compareInnerHtml( + '

foobar

', + '

foobar

' ) ); } } ); } )(); \ No newline at end of file From d8b3a7a2b9c208bbdbdc6721405bf598529371f8 Mon Sep 17 00:00:00 2001 From: Piotr Jasiun Date: Mon, 2 Mar 2015 16:01:00 +0100 Subject: [PATCH 4/4] Tests: added `range` tag to getextracthtmlfromrange tests. --- tests/core/editable/getextracthtmlfromrange.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/core/editable/getextracthtmlfromrange.js b/tests/core/editable/getextracthtmlfromrange.js index e3de3f751bc..602eb1b551e 100644 --- a/tests/core/editable/getextracthtmlfromrange.js +++ b/tests/core/editable/getextracthtmlfromrange.js @@ -1,4 +1,4 @@ -/* bender-tags: editor,unit */ +/* bender-tags: editor,unit,range */ ( function() { 'use strict';