Forráskód Böngészése

Testing multiple styles setting in treeView.Element.

Szymon Kupś 9 éve
szülő
commit
f11a772965

+ 9 - 2
packages/ckeditor5-engine/src/treeview/element.js

@@ -446,8 +446,15 @@ export default class Element extends Node {
 	/**
 	 * Adds style to the element.
 	 *
-	 * @param {String} property
-	 * @param {String} value
+	 * @example
+	 * element.setStyle( 'color', 'red' );
+	 * element.setStyle( {
+	 * 		color: 'red',
+	 * 		position: 'fixed'
+	 * } );
+	 *
+	 * @param {String|Object} property Property name or object with property - value pairs.
+	 * @param {String} value Value to set. This parameter is ignored if object is provided as the first parameter.
 	 * @fires core.treeView.Node#change
 	 */
 	setStyle( property, value ) {

+ 13 - 0
packages/ckeditor5-engine/tests/treeview/element.js

@@ -637,6 +637,19 @@ describe( 'Element', () => {
 
 			el.setStyle( 'color', 'red' );
 		} );
+
+		it( 'should set multiple styles by providing an object', () => {
+			const el = new ViewElement( 'p' );
+			el.setStyle( {
+				color: 'red',
+				position: 'fixed'
+			} );
+
+			expect( el._styles.has( 'color' ) ).to.be.true;
+			expect( el._styles.has( 'position' ) ).to.be.true;
+			expect( el._styles.get( 'color' ) ).to.equal( 'red' );
+			expect( el._styles.get( 'position' ) ).to.equal( 'fixed' );
+		} );
 	} );
 
 	describe( 'getStyle', () => {