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

Commit

Permalink
Merge pull request #1822 from ckeditor/i/5854
Browse files Browse the repository at this point in the history
Other: Improved `parseAttributes` function performance. This results in improved editor data processing speed. Closes ckeditor/ckeditor5#5854.
  • Loading branch information
jodator authored Feb 6, 2020
2 parents 5106014 + 56bd240 commit ecaf056
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/view/element.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand Down Expand Up @@ -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 ) {
Expand Down

0 comments on commit ecaf056

Please sign in to comment.