Ver Fonte

More fixes to https://github.com/ckeditor/ckeditor5-engine/issues/454.

Szymon Kupś há 9 anos atrás
pai
commit
d42608484e

+ 2 - 0
packages/ckeditor5-engine/src/model/selection.js

@@ -498,6 +498,8 @@ export default class Selection {
 
 			// ...look for a first character node in that range and take attributes from it.
 			for ( let item of range ) {
+				// This is not an optimal solution because of https://github.com/ckeditor/ckeditor5-engine/issues/454.
+				// It can be done better by using `break;` instead of checking `attrs === null`.
 				if ( item.type == 'TEXT' && attrs === null ) {
 					attrs = item.item.getAttributes();
 				}

+ 5 - 1
packages/ckeditor5-engine/src/view/element.js

@@ -196,7 +196,11 @@ export default class Element extends Node {
 			yield 'style';
 		}
 
-		yield* this._attrs.keys();
+		// This is not an optimal solution because of https://github.com/ckeditor/ckeditor5-engine/issues/454.
+		// It can be simplified to `yield* this._attrs.keys();`.
+		for ( let key of this._attrs.keys() ) {
+			yield key;
+		}
 	}
 
 	/**

+ 2 - 2
packages/ckeditor5-engine/src/view/writer.js

@@ -799,7 +799,7 @@ function wrapAttributeElement( wrapper, toWrap ) {
 	}
 
 	// Check if attributes can be merged.
-	for ( let key of [ ...wrapper.getAttributeKeys() ] ) {
+	for ( let key of wrapper.getAttributeKeys() ) {
 		// Classes and styles should be checked separately.
 		if ( key === 'class' || key === 'style' ) {
 			continue;
@@ -860,7 +860,7 @@ function unwrapAttributeElement( wrapper, toUnwrap ) {
 	}
 
 	// Check if AttributeElement has all wrapper attributes.
-	for ( let key of [ ...wrapper.getAttributeKeys() ] ) {
+	for ( let key of wrapper.getAttributeKeys() ) {
 		// Classes and styles should be checked separately.
 		if ( key === 'class' || key === 'style' ) {
 			continue;