浏览代码

Removed Selection#clearAttributes.

Maciej Bukowski 7 年之前
父节点
当前提交
773c973358

+ 0 - 13
packages/ckeditor5-engine/src/model/liveselection.js

@@ -231,19 +231,6 @@ export default class LiveSelection extends Selection {
 	}
 
 	/**
-	 * @inheritDoc
-	 */
-	clearAttributes() {
-		const changed = this._setAttributesTo( new Map() );
-
-		if ( changed.size > 0 ) {
-			// Fire event with exact data (fire only if anything changed).
-			const attributeKeys = Array.from( changed );
-			this.fire( 'change:attribute', { attributeKeys, directChange: true } );
-		}
-	}
-
-	/**
 	 * Removes all attributes from the selection and sets attributes according to the surrounding nodes.
 	 *
 	 * @protected

+ 0 - 17
packages/ckeditor5-engine/src/model/selection.js

@@ -465,23 +465,6 @@ export default class Selection {
 	}
 
 	/**
-	 * Removes all attributes from the selection.
-	 *
-	 * If there were any attributes in selection, fires the {@link #event:change} event with
-	 * removed attributes' keys.
-	 *
-	 * @fires change:attribute
-	 */
-	clearAttributes() {
-		if ( this._attrs.size > 0 ) {
-			const attributeKeys = Array.from( this._attrs.keys() );
-			this._attrs.clear();
-
-			this.fire( 'change:attribute', { attributeKeys, directChange: true } );
-		}
-	}
-
-	/**
 	 * Removes an attribute with given key from the selection.
 	 *
 	 * If given attribute was set on the selection, fires the {@link #event:change} event with

+ 0 - 33
packages/ckeditor5-engine/tests/model/selection.js

@@ -1165,39 +1165,6 @@ describe( 'Selection', () => {
 			} );
 		} );
 
-		describe( 'clearAttributes()', () => {
-			it( 'should remove all attributes from the element', () => {
-				selection.setTo( [ rangeInFullP ] );
-				selection.setAttribute( 'foo', 'bar' );
-				selection.setAttribute( 'abc', 'xyz' );
-
-				selection.clearAttributes();
-
-				expect( selection.getAttribute( 'foo' ) ).to.be.undefined;
-				expect( selection.getAttribute( 'abc' ) ).to.be.undefined;
-			} );
-
-			it( 'should fire change:attribute event with correct parameters', () => {
-				selection.setAttribute( 'foo', 'bar' );
-
-				selection.on( 'change:attribute', ( evt, data ) => {
-					expect( data.directChange ).to.be.true;
-					expect( data.attributeKeys ).to.deep.equal( [ 'foo' ] );
-				} );
-
-				selection.clearAttributes();
-			} );
-
-			it( 'should not fire change:attribute event if there were no attributes', () => {
-				const spy = sinon.spy();
-				selection.on( 'change:attribute', spy );
-
-				selection.clearAttributes();
-
-				expect( spy.called ).to.be.false;
-			} );
-		} );
-
 		describe( 'removeAttribute()', () => {
 			it( 'should remove attribute', () => {
 				selection.setTo( [ rangeInFullP ] );