Properly return inherited methods in property getter in spoof-css scriptlet

Related feedback:
- https://github.com/uBlockOrigin/uBlock-issues/issues/2618#issuecomment-1561451479
This commit is contained in:
Raymond Hill 2023-05-24 14:58:12 -04:00
parent 1d9ee00498
commit d4fb87b6ba
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 7 additions and 3 deletions

View File

@ -2262,6 +2262,9 @@ function spoofCSS(
proxiedStyles.add(target);
const proxiedStyle = new Proxy(style, {
get(target, prop, receiver) {
if ( typeof target[prop] === 'function' ) {
return target[prop].bind(target);
}
return spoofStyle(prop, Reflect.get(target, prop, receiver));
},
});
@ -2349,9 +2352,10 @@ function spoofCSS(
**/
builtinScriptlets.push({
name: 'sed.js',
name: 'replace-node-text.js',
requiresTrust: true,
fn: sed,
aliases: [ 'rnt.js', 'sed.js' /* to be removed */ ],
fn: replaceNodeText,
world: 'ISOLATED',
dependencies: [
'get-extra-args.fn',
@ -2360,7 +2364,7 @@ builtinScriptlets.push({
'safe-self.fn',
],
});
function sed(
function replaceNodeText(
nodeName = '',
pattern = '',
replacement = ''