Skip to content

Commit fb71fc8

Browse files
author
Piotr Jasiun
committed
Merge branch 't/12964' into major
2 parents 015c43d + d8b3a7a commit fb71fc8

File tree

5 files changed

+55
-15
lines changed

5 files changed

+55
-15
lines changed

bender.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,7 @@ var config = {
5757
'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace #9': 'env.safari',
5858
'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #2': 'env.safari',
5959
'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #3': 'env.safari',
60-
'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #8': 'env.safari',
61-
62-
// IE8-10 (#12964)
63-
'tests/core/editable/getextractselectedhtml#test extractHtmlFromRange: tables #20': 'env.ie && env.version < 11'
60+
'tests/core/editable/keystrokes/delbackspacequirks/collapsed#test backspace, merge #8': 'env.safari'
6461
}
6562
},
6663

core/editable.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2735,9 +2735,21 @@
27352735
editableRange,
27362736
walker = new CKEDITOR.dom.walker( range ),
27372737
startCell = range.startPath().contains( tableEditable ),
2738-
endCell = range.endPath().contains( tableEditable );
2738+
endCell = range.endPath().contains( tableEditable ),
2739+
database = {};
27392740

27402741
walker.guard = function( node, leaving ) {
2742+
// Guard may be executed on some node boundaries multiple times,
2743+
// what results in creating more than one range for each selected cell. (#12964)
2744+
if ( node.type == CKEDITOR.NODE_ELEMENT ) {
2745+
var key = 'visited_' + ( leaving ? 'out' : 'in' );
2746+
if ( node.getCustomData( key ) ) {
2747+
return;
2748+
}
2749+
2750+
CKEDITOR.dom.element.setMarker( database, node, key, 1 );
2751+
}
2752+
27412753
// Handle partial selection in a cell in which the range starts:
27422754
// <td><p>x{xx</p></td>...
27432755
// will store:
@@ -2771,6 +2783,9 @@
27712783

27722784
walker.lastForward();
27732785

2786+
// Clear all markers so next extraction will not be affected by this one.
2787+
CKEDITOR.dom.element.clearAllMarkers( database );
2788+
27742789
return contentsRanges;
27752790

27762791
function checkRemoveCellContents( node ) {

tests/_benderjs/ckeditor/static/tools.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,6 +1442,11 @@
14421442
fixZWS = ( 'fixZWS' in options ) ? options.fixZWS : true,
14431443
fixNbsp = ( 'fixNbsp' in options ) ? options.fixNbsp : true;
14441444

1445+
// On IE8- we need to get rid of expando attributes.
1446+
if ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) {
1447+
innerHtml = innerHtml.replace( / data-cke-expando="[^"]*"/g, '' );
1448+
}
1449+
14451450
if ( options.compareSelection ) {
14461451
innerHtml = innerHtml.replace( selectionMarkers, '<!--cke-range-marker-$1-->' );
14471452
}

tests/core/editable/getextracthtmlfromrange.js

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* bender-tags: editor,unit */
1+
/* bender-tags: editor,unit,range */
22

33
( function() {
44
'use strict';
@@ -24,15 +24,6 @@
2424
getWithHtml = bender.tools.range.getWithHtml,
2525
img_src = '%BASE_PATH%_assets/img.gif';
2626

27-
var tests = {
28-
init: function() {
29-
this.editables = {};
30-
31-
for ( var e in this.editors )
32-
this.editables[ e ] = this.editors[ e ].editable();
33-
}
34-
};
35-
3627
// <DEV>
3728
// var playground = CKEDITOR.document.createElement( 'dl' );
3829
// playground.on( 'paste', function( e ) {
@@ -110,6 +101,28 @@
110101
// output HTML | @ | like compareInnerHtml (accept) | like compareInnerHtml (we use it for uncertain cases)
111102
// | @! | like compareInnerHtml (expect) | like compareInnerHtml (we use it for empty blocks)
112103

104+
var tests = {
105+
init: function() {
106+
this.editables = {};
107+
108+
for ( var e in this.editors )
109+
this.editables[ e ] = this.editors[ e ].editable();
110+
},
111+
112+
'test node markers are cleared': function() {
113+
var html = decodeInputFillers( '<table><tbody><tr><td>a{b</td><td>c}d</td></tr></tbody></table>' ),
114+
expected = '<table><tbody><tr><td>b</td><td>c</td></tr></tbody></table>',
115+
editable = this.editables.inline,
116+
range = setWithHtml( editable, html );
117+
118+
var docFragment = editable.extractHtmlFromRange( range );
119+
120+
assert.isInnerHtmlMatching( expected, docFragment.getHtml(), compareInnerHtmlOptions, 'Selected HTML' );
121+
assert.isNull( editable.findOne( 'tr' ).getChild( 0 ).getCustomData( 'visited_out' ), '1st cell should not have a marker' );
122+
assert.isNull( editable.findOne( 'tr' ).getChild( 1 ).getCustomData( 'visited_in' ), '2nd cell should not have a marker' );
123+
}
124+
};
125+
113126
addTests( {
114127
'block': [
115128
[ '<p>{a}</p>', 'a', '<p>[]@!</p>' ],

tests/utils/html/compareinnerhtml.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,16 @@
154154
htmlTools.compareInnerHtml( 'a', 'a', opts );
155155

156156
assert.areSame( strOpts, JSON.stringify( opts ), 'options object has not been modified' );
157+
},
158+
159+
'test on IE8 expando attributes are removed': function() {
160+
if ( !CKEDITOR.env.ie || CKEDITOR.env.version > 8 ) {
161+
assert.ignore();
162+
}
163+
164+
assert.isTrue( htmlTools.compareInnerHtml(
165+
'<p>foo<i bar="2" foo="1">bar</i></p>',
166+
'<p data-cke-expando="123ok">foo<i foo="1" data-cke-expando="" bar="2">bar</i></p>' ) );
157167
}
158168
} );
159169
} )();

0 commit comments

Comments
 (0)