mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Throws error if either data-target or data-text were passed and throws error if neither data-target nor data-text were passed too
This commit is contained in:
@ -8,19 +8,25 @@ class ClipboardAction {
|
||||
*/
|
||||
constructor(options) {
|
||||
this.action = options.action;
|
||||
this.emitter = options.emitter;
|
||||
this.emitter = options.emitter;
|
||||
this.target = options.target;
|
||||
this.text = options.text;
|
||||
this.trigger = options.trigger;
|
||||
|
||||
this.selectedText = '';
|
||||
|
||||
if (this.text) {
|
||||
if (this.text && this.target) {
|
||||
throw new Error('Multiple attributes declared, use either "data-target" or "data-text"');
|
||||
}
|
||||
else if (this.text) {
|
||||
this.selectFake();
|
||||
}
|
||||
else if (this.target) {
|
||||
this.selectTarget();
|
||||
}
|
||||
else {
|
||||
throw new Error('Missing required attributes, use either "data-target" or "data-text"');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user