Source formatting and testing for #24

This commit is contained in:
Zeno Rocha
2015-10-03 19:04:37 -07:00
parent cc9d562580
commit 0c24503214
2 changed files with 53 additions and 1 deletions

View File

@ -34,7 +34,15 @@ class Clipboard extends Emitter {
* @param {String} selector
*/
delegateClick(selector) {
Delegate.bind(document.body, selector, 'click', (e) => this.onClick(e));
this.binding = Delegate.bind(document.body, selector, 'click', (e) => this.onClick(e));
}
/**
* Undelegates a click event on body.
* @param {String} selector
*/
undelegateClick() {
Delegate.unbind(document.body, 'click', this.binding);
}
/**
@ -82,6 +90,18 @@ class Clipboard extends Emitter {
defaultText(trigger) {
return getAttributeValue('text', trigger);
}
/**
* Destroy lifecycle.
*/
destroy() {
this.undelegateClick();
if (this.clipboardAction) {
this.clipboardAction.destroy();
this.clipboardAction = null;
}
}
}