chore(clipboard): remove linter bugs

This commit is contained in:
r3nanp 2021-02-13 10:56:07 -03:00
parent da6b7dd7a3
commit b21b99fe5f
2 changed files with 21 additions and 18 deletions

View File

@ -45,7 +45,7 @@ class ClipboardAction {
* and makes a selection on it.
*/
selectFake() {
const isRTL = document.documentElement.getAttribute('dir') == 'rtl';
const isRTL = document.documentElement.getAttribute('dir') === 'rtl';
this.removeFake();

View File

@ -1,11 +1,28 @@
import ClipboardAction from './clipboard-action';
/* eslint-disable class-methods-use-this */
/* eslint-disable consistent-return */
import Emitter from 'tiny-emitter';
import listen from 'good-listener';
import ClipboardAction from './clipboard-action';
/**
* Base class which takes one or more elements, adds event listeners to them,
* and instantiates a new `ClipboardAction` on each click.
*/
/**
* Helper function to retrieve attribute value.
* @param {String} suffix
* @param {Element} element
*/
function getAttributeValue(suffix, element) {
const attribute = `data-clipboard-${suffix}`;
if (!element.hasAttribute(attribute)) {
return;
}
return element.getAttribute(attribute);
}
class Clipboard extends Emitter {
/**
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
@ -62,7 +79,7 @@ class Clipboard extends Emitter {
target: this.target(trigger),
text: this.text(trigger),
container: this.container,
trigger: trigger,
trigger,
emitter: this,
});
}
@ -96,6 +113,7 @@ class Clipboard extends Emitter {
const actions = typeof action === 'string' ? [action] : action;
let support = !!document.queryCommandSupported;
// eslint-disable-next-line no-shadow
actions.forEach((action) => {
support = support && !!document.queryCommandSupported(action);
});
@ -124,19 +142,4 @@ class Clipboard extends Emitter {
}
}
/**
* Helper function to retrieve attribute value.
* @param {String} suffix
* @param {Element} element
*/
function getAttributeValue(suffix, element) {
const attribute = `data-clipboard-${suffix}`;
if (!element.hasAttribute(attribute)) {
return;
}
return element.getAttribute(attribute);
}
export default Clipboard;