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

Commit

Permalink
Removed Selection#clearAttributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
ma2ciek committed Jan 24, 2018
1 parent d8029cf commit 84fa8ba
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 63 deletions.
13 changes: 0 additions & 13 deletions src/model/liveselection.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,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.
*
Expand Down
17 changes: 0 additions & 17 deletions src/model/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,23 +464,6 @@ export default class Selection {
return this._attrs.has( key );
}

/**
* 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.
*
Expand Down
33 changes: 0 additions & 33 deletions tests/model/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ] );
Expand Down

0 comments on commit 84fa8ba

Please sign in to comment.