Changes target to support selector instead of id

This commit is contained in:
Eduardo Lundgren
2015-09-28 23:37:58 -03:00
parent 1ce64f39a2
commit beab7bc087
2 changed files with 11 additions and 11 deletions

View File

@ -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');