Skip to content
Permalink
Browse files

Merge branch 't/7975'

  • Loading branch information...
Reinmar committed Jun 13, 2014
2 parents d5410f1 + 59b75c9 commit 850b2e4e5969628e532c2cefe9388f886b52a4ad
Showing with 42 additions and 2 deletions.
  1. +1 −0 CHANGES.md
  2. +4 −1 core/selection.js
  3. +37 −1 tests/core/selection/selection.js
@@ -22,6 +22,7 @@ Fixed Issues:
* [#11980](http://dev.ckeditor.com/ticket/11980): [Blink/Webkit] Fixed: Span elements created while joining adjacent elements (non-collapsed selection).
* [#12009](http://dev.ckeditor.com/ticket/12009): [Nested widgets] Integration with Magicline plugin.
* [#11387](http://dev.ckeditor.com/ticket/11387): Fixed: `role="radiogroup"` should be applied only to radio inputs' container.
* [#7975](http://dev.ckeditor.com/ticket/7975): [IE8] Fixed: Errors when trying to select empty table cell on IE8.

## CKEditor 4.4.1

@@ -1808,8 +1808,11 @@

// IE doesn't support selecting the entire table row/cell, move the selection into cells, e.g.
// <table><tbody><tr>[<td>cell</b></td>... => <table><tbody><tr><td>[cell</td>...
if ( range.startContainer.type == CKEDITOR.NODE_ELEMENT && range.startContainer.getName() in nonCells || range.endContainer.type == CKEDITOR.NODE_ELEMENT && range.endContainer.getName() in nonCells )
if ( range.startContainer.type == CKEDITOR.NODE_ELEMENT && range.startContainer.getName() in nonCells || range.endContainer.type == CKEDITOR.NODE_ELEMENT && range.endContainer.getName() in nonCells ) {
range.shrink( CKEDITOR.NODE_ELEMENT, true );
// The range might get collapsed (#7975). Update cached variable.
collapsed = range.collapsed;
}

var bookmark = range.createBookmark();

@@ -2,7 +2,7 @@

bender.editor = {
config: {
extraAllowedContent: 'div'
allowedContent: true
}
};

@@ -96,6 +96,42 @@ bender.test(
}
},

'test selectRanges - range containing table cell': function() {
var editor = this.editor,
range = bender.tools.range.setWithHtml( editor.editable(), '<table><tr><td>x</td>[<td>foo</td>]<td>x</td></tr></table>' );

editor.getSelection().selectRanges( [ range ] );

assert.areSame( 'foo', CKEDITOR.tools.trim( editor.getSelection().getSelectedText() ) );
},

'test selectRanges - range containing empty table cell': function() {
var editor = this.editor,
data = '<table><tbody><tr><td>x</td><td id="cell"></td><td>x</td></tr></tbody></table>';

this.editorBot.setData( data, function() {
var range = editor.createRange(),
cell = editor.document.getById( 'cell' );

range.setStartAt( cell, CKEDITOR.POSITION_BEFORE_START );
range.setEndAt( cell, CKEDITOR.POSITION_AFTER_END );

editor.getSelection().selectRanges( [ range ] );

var sel = editor.getSelection();

// IE8 && Webkit (precisely - excluding Blink) can't select cell from outside.
if ( ( CKEDITOR.env.ie && CKEDITOR.env.version < 9 ) || CKEDITOR.env.safari ) {
var selected = sel.getStartElement();
assert.isTrue( cell.equals( selected ) || cell.contains( selected ), 'selection is inside the cell' );
} else
assert.areSame( cell, sel.getSelectedElement(), 'cell is selected' );

// I saw some strange span being left by IE8. Let's check data to be safe.
assert.areSame( data, editor.getData().replace( /&nbsp;|\u00a0/, '' ), 'data is ok' );
} );
},

test_getSelectedElement : function() {
testSelectedElement( '[<img />]', 'img' );
testSelectedElement( '[<hr />]', 'hr' );

0 comments on commit 850b2e4

Please sign in to comment.
You can’t perform that action at this time.