瀏覽代碼

Internal: Further improved performance by cheaper type checks.

The isPlainObject method is pretty slow, and given that elements are created intensively, reducing cost of this brings notable gains.
Marek Lewandowski 6 年之前
父節點
當前提交
531025cf42
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      packages/ckeditor5-engine/src/view/element.js

+ 3 - 3
packages/ckeditor5-engine/src/view/element.js

@@ -859,10 +859,10 @@ export default class Element extends Node {
 // @param {Object|Map} attrs Attributes to parse.
 // @returns {Map} Parsed attributes.
 function parseAttributes( attrs ) {
-	if ( isPlainObject( attrs ) ) {
-		attrs = objectToMap( attrs );
-	} else {
+	if ( attrs instanceof Map ) {
 		attrs = new Map( attrs );
+	} else {
+		attrs = objectToMap( attrs );
 	}
 
 	for ( const [ key, value ] of attrs ) {