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

Commit 16b0280

Browse files
authored
Merge pull request #1502 from dimaip/patch-1
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!
2 parents ef5960e + 99747a8 commit 16b0280

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/view/filler.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@
33
* For licensing, see LICENSE.md.
44
*/
55

6-
/* globals window, Text */
6+
/* globals window */
77

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

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

9091
/**

tests/view/filler.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ describe( 'filler', () => {
111111

112112
expect( isInlineFiller( node ) ).to.be.false;
113113
} );
114+
115+
it( 'should be true for inline filler from inside iframe', () => {
116+
const iframe = document.createElement( 'iframe' );
117+
document.body.appendChild( iframe );
118+
const node = iframe.contentDocument.createTextNode( INLINE_FILLER );
119+
120+
expect( isInlineFiller( node ) ).to.be.true;
121+
122+
document.body.removeChild( iframe );
123+
} );
114124
} );
115125

116126
describe( 'isBlockFiller', () => {

0 commit comments

Comments
 (0)