Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'set-constant' — setProxyTrap() #403

Closed
AdamWr opened this issue Feb 12, 2024 · 0 comments
Closed

Fix 'set-constant' — setProxyTrap() #403

AdamWr opened this issue Feb 12, 2024 · 0 comments

Comments

@AdamWr
Copy link
Member

AdamWr commented Feb 12, 2024

Currently it doesn't work correctly for falsy values.

Steps to reproduce:

  1. Add this rule:
example.org#%#//scriptlet('set-constant', 'foo.bar.test', 'true', '', '', 'true')
  1. Go to - https://example.org/
  2. In browser console run:
Code:
foo = {
  bar: {
    abc: {}
  }
};
console.log('Original foo.bar - foo.bar.test:', foo.bar.test);
foo.bar = {
  abc: {},
};
console.log('Rewritten foo.bar - foo.bar.test:', foo.bar.test);

or

Code:
foo = {
  bar: {
    abc: {}
  }
};
console.log('Original foo.bar - foo.bar.test:', foo.bar.test);
foo.bar = {
  abc: {},
  test: false,
};
console.log('Rewritten foo.bar - foo.bar.test:', foo.bar.test);

foo.bar.test should returns true.

Probably currentObj && should be removed from:

if (currentObj && index === array.length - 1 && currentObj !== constantValue) {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants