8
0
Quellcode durchsuchen

Removed support for decorating multiple methods at once.

Piotrek Koszuliński vor 8 Jahren
Ursprung
Commit
eca7e73d49
1 geänderte Dateien mit 22 neuen und 24 gelöschten Zeilen
  1. 22 24
      packages/ckeditor5-utils/src/observablemixin.js

+ 22 - 24
packages/ckeditor5-utils/src/observablemixin.js

@@ -303,34 +303,32 @@ const ObservableMixin = {
 	 *
 	 *		foo.method( 1, 2 ); // -> '3, 2'
 	 *
-	 * @param {String} ...methodNames Names of the methods to decorate.
+	 * @param {String} methodName Name of the method to decorate.
 	 */
-	decorate( ...methodNames ) {
-		methodNames.forEach( methodName => {
-			const originalMethod = this[ methodName ];
+	decorate( methodName ) {
+		const originalMethod = this[ methodName ];
 
-			if ( !originalMethod ) {
-				/**
-				 * Cannot decorate an undefined method.
-				 *
-				 * @error observablemixin-cannot-decorate-undefined
-				 * @param {Object} object The object on which you try to decorate a method.
-				 * @param {String} methodName Name of the method which does not exist.
-				 */
-				throw new CKEditorError(
-					'observablemixin-cannot-decorate-undefined: Cannot decorate an undefined method.',
-					{ object: this, methodName }
-				);
-			}
-
-			this.on( methodName, ( evt, args ) => {
-				evt.return = originalMethod.apply( this, args );
-			} );
+		if ( !originalMethod ) {
+			/**
+			 * Cannot decorate an undefined method.
+			 *
+			 * @error observablemixin-cannot-decorate-undefined
+			 * @param {Object} object The object which method should be decorated.
+			 * @param {String} methodName Name of the method which does not exist.
+			 */
+			throw new CKEditorError(
+				'observablemixin-cannot-decorate-undefined: Cannot decorate an undefined method.',
+				{ object: this, methodName }
+			);
+		}
 
-			this[ methodName ] = function( ...args ) {
-				return this.fire( methodName, args );
-			};
+		this.on( methodName, ( evt, args ) => {
+			evt.return = originalMethod.apply( this, args );
 		} );
+
+		this[ methodName ] = function( ...args ) {
+			return this.fire( methodName, args );
+		};
 	}
 
 	/**