mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-03 09:39:38 +02:00
Prevent only target (leaf) property from being overtaken
Related discussion:
- https://github.com/uBlockOrigin/uBlock-issues/issues/156#issuecomment-707095193
Related commit:
- 6e010ecc0f
This commit is contained in:
parent
b38f7b9899
commit
a08f33e09d
@ -741,7 +741,7 @@
|
|||||||
};
|
};
|
||||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/156
|
// https://github.com/uBlockOrigin/uBlock-issues/issues/156
|
||||||
// Support multiple trappers for the same property.
|
// Support multiple trappers for the same property.
|
||||||
const trapProp = function(owner, prop, handler) {
|
const trapProp = function(owner, prop, configurable, handler) {
|
||||||
if ( handler.init(owner[prop]) === false ) { return; }
|
if ( handler.init(owner[prop]) === false ) { return; }
|
||||||
const odesc = Object.getOwnPropertyDescriptor(owner, prop);
|
const odesc = Object.getOwnPropertyDescriptor(owner, prop);
|
||||||
let prevGetter, prevSetter;
|
let prevGetter, prevSetter;
|
||||||
@ -754,7 +754,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Object.defineProperty(owner, prop, {
|
Object.defineProperty(owner, prop, {
|
||||||
configurable: false,
|
configurable,
|
||||||
get() {
|
get() {
|
||||||
if ( prevGetter !== undefined ) {
|
if ( prevGetter !== undefined ) {
|
||||||
prevGetter();
|
prevGetter();
|
||||||
@ -772,7 +772,7 @@
|
|||||||
const trapChain = function(owner, chain) {
|
const trapChain = function(owner, chain) {
|
||||||
const pos = chain.indexOf('.');
|
const pos = chain.indexOf('.');
|
||||||
if ( pos === -1 ) {
|
if ( pos === -1 ) {
|
||||||
trapProp(owner, chain, {
|
trapProp(owner, chain, false, {
|
||||||
v: undefined,
|
v: undefined,
|
||||||
init: function(v) {
|
init: function(v) {
|
||||||
if ( mustAbort(v) ) { return false; }
|
if ( mustAbort(v) ) { return false; }
|
||||||
@ -798,7 +798,7 @@
|
|||||||
trapChain(v, chain);
|
trapChain(v, chain);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
trapProp(owner, prop, {
|
trapProp(owner, prop, true, {
|
||||||
v: undefined,
|
v: undefined,
|
||||||
init: function(v) {
|
init: function(v) {
|
||||||
this.v = v;
|
this.v = v;
|
||||||
|
Loading…
Reference in New Issue
Block a user