|
|
@@ -297,37 +297,82 @@ describe( 'DomConverter', () => {
|
|
|
converter = new DomConverter( { blockFillerMode: 'nbsp' } );
|
|
|
} );
|
|
|
|
|
|
- it( 'should return true if the node is an instance of the NBSP block filler', () => {
|
|
|
- converter = new DomConverter( { blockFillerMode: 'nbsp' } );
|
|
|
+ it( 'should return true if the node is an nbsp filler and is a single child of a block level element', () => {
|
|
|
const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
|
|
|
- // NBSP must be check inside a context.
|
|
|
+
|
|
|
const context = document.createElement( 'div' );
|
|
|
context.appendChild( nbspFillerInstance );
|
|
|
|
|
|
expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.true;
|
|
|
} );
|
|
|
|
|
|
- it( 'should return false if the node is an instance of the BR block filler', () => {
|
|
|
- const brFillerInstance = BR_FILLER( document ); // eslint-disable-line new-cap
|
|
|
+ it( 'should return false if the node is an nbsp filler and is not a single child of a block level element', () => {
|
|
|
+ const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
|
|
|
|
|
|
- expect( converter.isBlockFiller( brFillerInstance ) ).to.be.false;
|
|
|
+ const context = document.createElement( 'div' );
|
|
|
+ context.appendChild( nbspFillerInstance );
|
|
|
+ context.appendChild( document.createTextNode( 'a' ) );
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
- it( 'should return false if the nbsp filler is inside context', () => {
|
|
|
- converter = new DomConverter( { blockFillerMode: 'nbsp' } );
|
|
|
+ it( 'should return false if there are two nbsp fillers in a block element', () => {
|
|
|
const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
|
|
|
- // NBSP must be check inside a context.
|
|
|
+
|
|
|
const context = document.createElement( 'div' );
|
|
|
context.appendChild( nbspFillerInstance );
|
|
|
- // eslint-disable-next-line new-cap
|
|
|
- context.appendChild( NBSP_FILLER( document ) );
|
|
|
+ context.appendChild( NBSP_FILLER( document ) ); // eslint-disable-line new-cap
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return false filler is placed in a non-block element', () => {
|
|
|
+ const nbspFillerInstance = NBSP_FILLER( document ); // eslint-disable-line new-cap
|
|
|
+
|
|
|
+ const context = document.createElement( 'span' );
|
|
|
+ context.appendChild( nbspFillerInstance );
|
|
|
|
|
|
expect( converter.isBlockFiller( nbspFillerInstance ) ).to.be.false;
|
|
|
} );
|
|
|
|
|
|
+ it( 'should return false if the node is an instance of the BR block filler', () => {
|
|
|
+ const brFillerInstance = BR_FILLER( document ); // eslint-disable-line new-cap
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( brFillerInstance ) ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
it( 'should return false for inline filler', () => {
|
|
|
expect( converter.isBlockFiller( document.createTextNode( INLINE_FILLER ) ) ).to.be.false;
|
|
|
} );
|
|
|
+
|
|
|
+ it( 'should return false for a normal <br> element', () => {
|
|
|
+ const context = document.createElement( 'div' );
|
|
|
+ context.innerHTML = 'x<br>x';
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( context.childNodes[ 1 ] ) ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ // SPECIAL CASE (see ckeditor5#5564).
|
|
|
+ it( 'should return true for a <br> element which is the only child of its block parent', () => {
|
|
|
+ const context = document.createElement( 'div' );
|
|
|
+ context.innerHTML = '<br>';
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( context.firstChild ) ).to.be.true;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return false for a <br> element which is the only child of its non-block parent', () => {
|
|
|
+ const context = document.createElement( 'span' );
|
|
|
+ context.innerHTML = '<br>';
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( context.firstChild ) ).to.be.false;
|
|
|
+ } );
|
|
|
+
|
|
|
+ it( 'should return false for a <br> element which is followed by an nbsp', () => {
|
|
|
+ const context = document.createElement( 'span' );
|
|
|
+ context.innerHTML = '<br> ';
|
|
|
+
|
|
|
+ expect( converter.isBlockFiller( context.firstChild ) ).to.be.false;
|
|
|
+ } );
|
|
|
} );
|
|
|
|
|
|
describe( 'mode "br"', () => {
|