This repository was archived by the owner on Jun 26, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -159,6 +159,10 @@ export default class Writer {
159159 insert ( item , itemOrPosition , offset = 0 ) {
160160 this . _assertWriterUsedCorrectly ( ) ;
161161
162+ if ( item instanceof Text && item . data == '' ) {
163+ return ;
164+ }
165+
162166 const position = Position . _createAt ( itemOrPosition , offset ) ;
163167
164168 // If item has a parent already.
Original file line number Diff line number Diff line change @@ -158,6 +158,18 @@ describe( 'Writer', () => {
158158 expect ( Array . from ( parent . getChildren ( ) ) ) . to . deep . equal ( [ child1 , child2 , child3 ] ) ;
159159 } ) ;
160160
161+ it ( 'should do nothing if empty text node is being inserted' , ( ) => {
162+ const parent = createDocumentFragment ( ) ;
163+
164+ model . enqueueChange ( batch , writer => {
165+ const text = writer . createText ( '' ) ;
166+
167+ writer . insert ( text , parent ) ;
168+ } ) ;
169+
170+ expect ( parent . childCount ) . to . equal ( 0 ) ;
171+ } ) ;
172+
161173 it ( 'should create proper operation for inserting element' , ( ) => {
162174 const parent = createDocumentFragment ( ) ;
163175 const element = createElement ( 'child' ) ;
You can’t perform that action at this time.
0 commit comments