8
0
Просмотр исходного кода

Merge pull request #1822 from ckeditor/i/5854

Other: Improved `parseAttributes` function performance. This results in improved editor data processing speed. Closes ckeditor/ckeditor5#5854.
Maciej 6 лет назад
Родитель
Сommit
7438d6a6f3
1 измененных файлов с 4 добавлено и 9 удалено
  1. 4 9
      packages/ckeditor5-engine/src/view/element.js

+ 4 - 9
packages/ckeditor5-engine/src/view/element.js

@@ -10,10 +10,9 @@
 import Node from './node';
 import Text from './text';
 import TextProxy from './textproxy';
-import objectToMap from '@ckeditor/ckeditor5-utils/src/objecttomap';
+import toMap from '@ckeditor/ckeditor5-utils/src/tomap';
 import isIterable from '@ckeditor/ckeditor5-utils/src/isiterable';
 import Matcher from './matcher';
-import { isPlainObject } from 'lodash-es';
 import StylesMap from './stylesmap';
 
 // @if CK_DEBUG_ENGINE // const { convertMapToTags } = require( '../dev-utils/utils' );
@@ -853,17 +852,13 @@ export default class Element extends Node {
 }
 
 // Parses attributes provided to the element constructor before they are applied to an element. If attributes are passed
-// as an object (instead of `Map`), the object is transformed to the map. Attributes with `null` value are removed.
+// as an object (instead of `Iterable`), the object is transformed to the map. Attributes with `null` value are removed.
 // Attributes with non-`String` value are converted to `String`.
 //
-// @param {Object|Map} attrs Attributes to parse.
+// @param {Object|Iterable} attrs Attributes to parse.
 // @returns {Map} Parsed attributes.
 function parseAttributes( attrs ) {
-	if ( isPlainObject( attrs ) ) {
-		attrs = objectToMap( attrs );
-	} else {
-		attrs = new Map( attrs );
-	}
+	attrs = toMap( attrs );
 
 	for ( const [ key, value ] of attrs ) {
 		if ( value === null ) {