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

Commit a7ae813

Browse files
authored
Merge pull request #1762 from ckeditor/t/ckeditor5/1875
Fix: Fixed problem with handling very large text nodes.
2 parents 0a268ab + 7455550 commit a7ae813

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/model/differ.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,19 +1112,25 @@ function _generateActionsFromChanges( oldChildrenLength, changes ) {
11121112
for ( const change of changes ) {
11131113
// First, fill "holes" between changes with "equal" actions.
11141114
if ( change.offset > offset ) {
1115-
actions.push( ...'e'.repeat( change.offset - offset ).split( '' ) );
1115+
for ( let i = 0; i < change.offset - offset; i++ ) {
1116+
actions.push( 'e' );
1117+
}
11161118

11171119
oldChildrenHandled += change.offset - offset;
11181120
}
11191121

11201122
// Then, fill up actions accordingly to change type.
11211123
if ( change.type == 'insert' ) {
1122-
actions.push( ...'i'.repeat( change.howMany ).split( '' ) );
1124+
for ( let i = 0; i < change.howMany; i++ ) {
1125+
actions.push( 'i' );
1126+
}
11231127

11241128
// The last handled offset is after inserted range.
11251129
offset = change.offset + change.howMany;
11261130
} else if ( change.type == 'remove' ) {
1127-
actions.push( ...'r'.repeat( change.howMany ).split( '' ) );
1131+
for ( let i = 0; i < change.howMany; i++ ) {
1132+
actions.push( 'r' );
1133+
}
11281134

11291135
// The last handled offset is at the position where the nodes were removed.
11301136
offset = change.offset;
@@ -1143,7 +1149,9 @@ function _generateActionsFromChanges( oldChildrenLength, changes ) {
11431149
// Fill "equal" actions at the end of actions set. Use `oldChildrenHandled` to see how many children
11441150
// has not been changed / removed at the end of their parent.
11451151
if ( oldChildrenHandled < oldChildrenLength ) {
1146-
actions.push( ...'e'.repeat( oldChildrenLength - oldChildrenHandled ).split( '' ) );
1152+
for ( let i = 0; i < oldChildrenLength - oldChildrenHandled - offset; i++ ) {
1153+
actions.push( 'e' );
1154+
}
11471155
}
11481156

11491157
return actions;

0 commit comments

Comments
 (0)