Fix Event API. Update demos. Update tests (#793)

This commit is contained in:
Beto Muniz
2022-02-02 12:13:00 -03:00
committed by GitHub
parent 9698b1176a
commit 7d675f5fc1
12 changed files with 59 additions and 26 deletions

View File

@ -69,17 +69,18 @@ class Clipboard extends Emitter {
*/
onClick(e) {
const trigger = e.delegateTarget || e.currentTarget;
const selectedText = ClipboardActionDefault({
action: this.action(trigger),
const action = this.action(trigger) || 'copy';
const text = ClipboardActionDefault({
action,
container: this.container,
target: this.target(trigger),
text: this.text(trigger),
});
// Fires an event based on the copy operation result.
this.emit(selectedText ? 'success' : 'error', {
action: this.action,
text: selectedText,
this.emit(text ? 'success' : 'error', {
action,
text,
trigger,
clearSelection() {
if (trigger) {