mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
use event's currentTarget instead of target
This commit is contained in:
parent
db575bb4df
commit
37136663df
@ -47,10 +47,10 @@ class Clipboard extends Emitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.clipboardAction = new ClipboardAction({
|
this.clipboardAction = new ClipboardAction({
|
||||||
action : this.action(e.target),
|
action : this.action(e.currentTarget),
|
||||||
target : this.target(e.target),
|
target : this.target(e.currentTarget),
|
||||||
text : this.text(e.target),
|
text : this.text(e.currentTarget),
|
||||||
trigger : e.target,
|
trigger : e.currentTarget,
|
||||||
emitter : this
|
emitter : this
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,14 @@ describe('Clipboard', () => {
|
|||||||
global.button.setAttribute('data-clipboard-text', 'foo');
|
global.button.setAttribute('data-clipboard-text', 'foo');
|
||||||
document.body.appendChild(global.button);
|
document.body.appendChild(global.button);
|
||||||
|
|
||||||
|
global.span = document.createElement('span');
|
||||||
|
global.span.innerHTML = 'bar';
|
||||||
|
|
||||||
|
global.button.appendChild(span);
|
||||||
|
|
||||||
global.event = {
|
global.event = {
|
||||||
target: global.button
|
target: global.button,
|
||||||
|
currentTarget: global.button
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -63,6 +69,14 @@ describe('Clipboard', () => {
|
|||||||
assert.instanceOf(clipboard.clipboardAction, ClipboardAction);
|
assert.instanceOf(clipboard.clipboardAction, ClipboardAction);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should use an event\'s currentTarget when not equal to target', () => {
|
||||||
|
let clipboard = new Clipboard('.btn');
|
||||||
|
let bubbledEvent = { target: global.span, currentTarget: global.button };
|
||||||
|
|
||||||
|
clipboard.onClick(bubbledEvent);
|
||||||
|
assert.instanceOf(clipboard.clipboardAction, ClipboardAction);
|
||||||
|
});
|
||||||
|
|
||||||
it('should throws exception target', done => {
|
it('should throws exception target', done => {
|
||||||
try {
|
try {
|
||||||
var clipboard = new Clipboard('.btn', {
|
var clipboard = new Clipboard('.btn', {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user