Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 't/12964' into major
  • Loading branch information
Piotr Jasiun committed Mar 2, 2015
2 parents 015c43d + d8b3a7a commit fb71fc8
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 15 deletions.
5 changes: 1 addition & 4 deletions bender.js
Expand Up @@ -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'
}
},

Expand Down
17 changes: 16 additions & 1 deletion core/editable.js
Expand Up @@ -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:
// <td><p>x{xx</p></td>...
// will store:
Expand Down Expand Up @@ -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 ) {
Expand Down
5 changes: 5 additions & 0 deletions tests/_benderjs/ckeditor/static/tools.js
Expand Up @@ -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, '<!--cke-range-marker-$1-->' );
}
Expand Down
33 changes: 23 additions & 10 deletions tests/core/editable/getextracthtmlfromrange.js
@@ -1,4 +1,4 @@
/* bender-tags: editor,unit */
/* bender-tags: editor,unit,range */

( function() {
'use strict';
Expand All @@ -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();
}
};

// <DEV>
// var playground = CKEDITOR.document.createElement( 'dl' );
// playground.on( 'paste', function( e ) {
Expand Down Expand Up @@ -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( '<table><tbody><tr><td>a{b</td><td>c}d</td></tr></tbody></table>' ),
expected = '<table><tbody><tr><td>b</td><td>c</td></tr></tbody></table>',
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': [
[ '<p>{a}</p>', 'a', '<p>[]@!</p>' ],
Expand Down
10 changes: 10 additions & 0 deletions tests/utils/html/compareinnerhtml.js
Expand Up @@ -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(
'<p>foo<i bar="2" foo="1">bar</i></p>',
'<p data-cke-expando="123ok">foo<i foo="1" data-cke-expando="" bar="2">bar</i></p>' ) );
}
} );
} )();

0 comments on commit fb71fc8

Please sign in to comment.