1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-04 16:47:15 +02:00

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

View File

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