Parcourir la source

Code refactoring to Model#bind private functions: used Array#every instead of Array#findIndex.

Aleksander Nowodzinski il y a 10 ans
Parent
commit
ac45cea5dd
1 fichiers modifiés avec 2 ajouts et 4 suppressions
  1. 2 4
      packages/ckeditor5-ui/src/model.js

+ 2 - 4
packages/ckeditor5-ui/src/model.js

@@ -363,9 +363,7 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], ( EmitterMixin, C
 	 * @returns {Boolean}
 	 */
 	function hasAttributes( model, attrs ) {
-		return attrs.findIndex( a => {
-			return Object.keys( model._attributes ).indexOf( a ) === -1;
-		} ) == -1;
+		return attrs.every( a => a in model._attributes );
 	}
 
 	/**
@@ -376,7 +374,7 @@ CKEDITOR.define( [ 'emittermixin', 'ckeditorerror', 'utils' ], ( EmitterMixin, C
 	 * @returns {Boolean}
 	 */
 	function isStringArray( arr ) {
-		return arr.findIndex( a => typeof a !== 'string' ) == -1;
+		return arr.every( a => typeof a == 'string' );
 	}
 
 	/**