mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-10 01:02:08 +01: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
1 changed files with 4 additions and 4 deletions
|
@ -741,7 +741,7 @@
|
|||
};
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/156
|
||||
// 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; }
|
||||
const odesc = Object.getOwnPropertyDescriptor(owner, prop);
|
||||
let prevGetter, prevSetter;
|
||||
|
@ -754,7 +754,7 @@
|
|||
}
|
||||
}
|
||||
Object.defineProperty(owner, prop, {
|
||||
configurable: false,
|
||||
configurable,
|
||||
get() {
|
||||
if ( prevGetter !== undefined ) {
|
||||
prevGetter();
|
||||
|
@ -772,7 +772,7 @@
|
|||
const trapChain = function(owner, chain) {
|
||||
const pos = chain.indexOf('.');
|
||||
if ( pos === -1 ) {
|
||||
trapProp(owner, chain, {
|
||||
trapProp(owner, chain, false, {
|
||||
v: undefined,
|
||||
init: function(v) {
|
||||
if ( mustAbort(v) ) { return false; }
|
||||
|
@ -798,7 +798,7 @@
|
|||
trapChain(v, chain);
|
||||
return;
|
||||
}
|
||||
trapProp(owner, prop, {
|
||||
trapProp(owner, prop, true, {
|
||||
v: undefined,
|
||||
init: function(v) {
|
||||
this.v = v;
|
||||
|
|
Loading…
Reference in a new issue