-
Notifications
You must be signed in to change notification settings - Fork 32
Fix 'trusted-click-element' — throws error when trying to set 'cancelBubble' #555
Copy link
Copy link
Open
Labels
Priority: P4Status: Code ReviewVersion: Scriptlets v2.3bugSomething isn't workingSomething isn't working
Description
Related to - AdguardTeam/AdguardFilters#228144
Steps to reproduce:
- Ensure that scriptlets library v2.2.16 or newer is used
- Add to user rules:
example.org#%#//scriptlet('trusted-click-element', '#whatever_test')- Navigate to - https://example.org/
- Run in console:
document.body.addEventListener('click', (event) => {
event.cancelBubble = true;
alert('Clicked');
});
document.body.click();Alert should be displayed, but it throws error: Uncaught TypeError: Illegal invocation.
It seems that adding:
set(target, property, value) {
return Reflect.set(target, property, value);
}here:
Scriptlets/src/helpers/click-utils.ts
Lines 83 to 93 in 5680d8d
| const proxied = new Proxy(event, { | |
| get(target, prop) { | |
| if (prop === 'isTrusted') { | |
| return true; | |
| } | |
| const val = Reflect.get(target, prop); | |
| if (typeof val === 'function') { | |
| return val.bind(target); | |
| } | |
| return val; | |
| }, |
fixes it.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Priority: P4Status: Code ReviewVersion: Scriptlets v2.3bugSomething isn't workingSomething isn't working
