diff --git a/src/clipboard-action.js b/src/clipboard-action.js index e6dd4ef..8a0b3a4 100644 --- a/src/clipboard-action.js +++ b/src/clipboard-action.js @@ -195,6 +195,13 @@ class ClipboardAction { get target() { return this._target; } + + /** + * Destroy lifecycle. + */ + destroy() { + this.removeFake(); + } } export default ClipboardAction; diff --git a/test/clipboard-action.js b/test/clipboard-action.js index a59a676..b1b5781 100644 --- a/test/clipboard-action.js +++ b/test/clipboard-action.js @@ -225,4 +225,18 @@ describe('ClipboardAction', () => { assert.equal(selectedText, ''); }); }); + + describe('#destroy', () => { + it('should destroy an existing fake element', () => { + let clip = new ClipboardAction({ + emitter: new Emitter(), + text: 'blah' + }); + + clip.selectFake(); + clip.destroy(); + + assert.equal(clip.fakeElem, null); + }); + }); });