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:
Raymond Hill 2020-10-12 11:00:30 -04:00
parent b38f7b9899
commit a08f33e09d
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 4 additions and 4 deletions

View File

@ -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;