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

Commit

Permalink
Merge 7611aad into 0e0cae6
Browse files Browse the repository at this point in the history
  • Loading branch information
scofalik committed Jan 3, 2019
2 parents 0e0cae6 + 7611aad commit 15d1382
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export default class Writer {
insert( item, itemOrPosition, offset = 0 ) {
this._assertWriterUsedCorrectly();

if ( item instanceof Text && item.data == '' ) {
return;
}

const position = Position._createAt( itemOrPosition, offset );

// If item has a parent already.
Expand Down
12 changes: 12 additions & 0 deletions tests/model/writer.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,18 @@ describe( 'Writer', () => {
expect( Array.from( parent.getChildren() ) ).to.deep.equal( [ child1, child2, child3 ] );
} );

it( 'should do nothing if empty text node is being inserted', () => {
const parent = createDocumentFragment();

model.enqueueChange( batch, writer => {
const text = writer.createText( '' );

writer.insert( text, parent );
} );

expect( parent.childCount ).to.equal( 0 );
} );

it( 'should create proper operation for inserting element', () => {
const parent = createDocumentFragment();
const element = createElement( 'child' );
Expand Down

0 comments on commit 15d1382

Please sign in to comment.