Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1502 from dimaip/patch-1
Browse files Browse the repository at this point in the history
Fix: `startsWithFiller` should correctly work with DOM `Text` nodes that are inside of an iframe.

Huge thanks to [Dmitri Pisarev](https://github.com/dimaip) for this contribution!
  • Loading branch information
scofalik authored Aug 20, 2018
2 parents ef5960e + 99747a8 commit 16b0280
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/view/filler.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
* For licensing, see LICENSE.md.
*/

/* globals window, Text */
/* globals window */

import { keyCodes } from '@ckeditor/ckeditor5-utils/src/keyboard';
import isText from '@ckeditor/ckeditor5-utils/src/dom/istext';

/**
* Set of utils related to block and inline fillers handling.
Expand Down Expand Up @@ -84,7 +85,7 @@ for ( let i = 0; i < INLINE_FILLER_LENGTH; i++ ) {
* @returns {Boolean} True if the text node starts with the {@link module:engine/view/filler~INLINE_FILLER inline filler}.
*/
export function startsWithFiller( domNode ) {
return ( domNode instanceof Text ) && ( domNode.data.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER );
return isText( domNode ) && ( domNode.data.substr( 0, INLINE_FILLER_LENGTH ) === INLINE_FILLER );
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/view/filler.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ describe( 'filler', () => {

expect( isInlineFiller( node ) ).to.be.false;
} );

it( 'should be true for inline filler from inside iframe', () => {
const iframe = document.createElement( 'iframe' );
document.body.appendChild( iframe );
const node = iframe.contentDocument.createTextNode( INLINE_FILLER );

expect( isInlineFiller( node ) ).to.be.true;

document.body.removeChild( iframe );
} );
} );

describe( 'isBlockFiller', () => {
Expand Down

0 comments on commit 16b0280

Please sign in to comment.