Skip to content

Commit

Permalink
Fixed: Error thrown while calling element.isBogus() on orphaned BRs (…
Browse files Browse the repository at this point in the history
…children of docFragment).
  • Loading branch information
oleq committed Jul 4, 2014
1 parent 02d035a commit 9da81b0
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions core/editable.js
Original file line number Diff line number Diff line change
Expand Up @@ -520,9 +520,15 @@
if ( node.type == CKEDITOR.NODE_TEXT )
node = node.getParent();

// Collect all <br>s and get rid of boguses.
var clonedFragment = rangeClone.cloneContents(),
boguses = new CKEDITOR.dom.nodeList( clonedFragment.$.querySelectorAll( 'br' ) ),
container = new CKEDITOR.dom.element( 'div' );

// Note: element.isBogus() fails work in documentFragment. Transfer
// documentFragment children to temp container to get rid of bogus <br>s.
clonedFragment.appendTo( container );

// Collect all <br>s and get rid of boguses.
var boguses = container.find( 'br' ),
bogusesToRemove = [];

for ( var i = boguses.count(), bogus; bogus = boguses.getItem( --i ); ) {
Expand All @@ -536,6 +542,9 @@
while ( ( bogus = bogusesToRemove.pop() ) )
bogus.remove();

// Move nodes back to documentFragment.
container.moveChildren( clonedFragment );

clonedFragment = rebuildFragmentTree.call( this, clonedFragment, node,
path.blockLimit.is( { tr: 1, table: 1 } ) ?
( function() {
Expand Down

0 comments on commit 9da81b0

Please sign in to comment.