Throws an error if selector is empty

This commit is contained in:
Zeno Rocha
2015-09-18 22:40:10 -07:00
parent 9f59fd4c59
commit 6ecabeb38f
2 changed files with 7 additions and 3 deletions

View File

@ -20,7 +20,12 @@ class Clipboard {
// Methods
init() {
[].forEach.call(this.triggers, (trigger) => this.bind(trigger));
if (this.triggers.length > 0) {
[].forEach.call(this.triggers, (trigger) => this.bind(trigger));
}
else {
throw new Error('The provided selector is empty');
}
}
bind(trigger) {
@ -83,7 +88,6 @@ class Clipboard {
window.getSelection().removeAllRanges();
}
catch (err) {
console.log(err);
throw new Error(err);
}
}