Skip to content

Commit

Permalink
extend proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
birm committed Mar 21, 2024
1 parent af163c3 commit b07912a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion common/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -354,9 +354,19 @@ function getUrlVars() {
vars[key.toLowerCase()] = value;
});

var state = Object.assign({}, vars); // Copy the initial state from vars

return new Proxy({}, {
get: function(target, prop) {
return vars[prop.toLowerCase()];
return state[prop.toLowerCase()];
},
set: function(target, prop, value) {
state[prop.toLowerCase()] = value;
return true;
},
deleteProperty: function(target, prop) {
delete state[prop.toLowerCase()];
return true;
}
});
}
Expand Down

0 comments on commit b07912a

Please sign in to comment.