From 8dc4e2e132b3beafc233852844442003b3d6de8a Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Sat, 3 Oct 2015 19:05:12 -0700 Subject: [PATCH] Adds destroy method for ClipboardAction too #24 --- src/clipboard-action.js | 7 +++++++ test/clipboard-action.js | 14 ++++++++++++++ 2 files changed, 21 insertions(+) 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); + }); + }); });