mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Changes target to support selector instead of id
This commit is contained in:
@ -157,13 +157,13 @@ class ClipboardAction {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the `target` property using the ID of an element
|
||||
* Sets the `target` property using the selector of an element
|
||||
* that will be have its content copied.
|
||||
* @param {String} target
|
||||
*/
|
||||
set target(target) {
|
||||
if (target) {
|
||||
this._target = document.getElementById(target);
|
||||
this._target = document.querySelector(target);
|
||||
|
||||
if (!this._target) {
|
||||
throw new Error('Invalid "data-clipboard-target" selector, use a value that matches an ID');
|
||||
|
Reference in New Issue
Block a user