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: ensure observer component name is only set when configurable #3831

Merged
merged 2 commits into from
Feb 22, 2024
Merged

fix: ensure observer component name is only set when configurable #3831

merged 2 commits into from
Feb 22, 2024

Conversation

kitsuned
Copy link
Contributor

this patch addresses issue with environments where function name property is not configurable, notably pre-ES2015.

the same condition exists in MobX: core/action.ts.

regarding tests, I couldn't find a feasible way to seal a function, which was also discussed in #2262.

$ podman run --rm node:0.12 node -p 'Object.getOwnPropertyDescriptor(function() {}, "name")'
{ value: '',
  writable: false,
  enumerable: false,
  configurable: false }

$ podman run --rm node:0.12 node -e 'Object.defineProperty(function() {}, "name", { value: "foobar" })'
[eval]:1
Object.defineProperty(function() {}, "name", { value: "foobar" })
       ^
TypeError: Cannot redefine property: name
    at Function.defineProperty (native)
    at [eval]:1:8
    at Object.exports.runInThisContext (vm.js:74:17)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:460:26)
    at evalScript (node.js:431:25)
    at startup (node.js:90:7)
    at node.js:814:3

Code change checklist

  • Added/updated unit tests
  • Updated /docs. For new functionality, at least API.md should be updated
  • Verified that there is no significant performance drop (yarn mobx test:performance)

this patch addresses issue with environments where function name property is not configurable, notably pre-ES2015
Copy link

changeset-bot bot commented Feb 15, 2024

🦋 Changeset detected

Latest commit: b994e02

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
mobx-react-lite Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@urugator
Copy link
Collaborator

LGTM Thank you!

@urugator urugator merged commit 1b8ab19 into mobxjs:main Feb 22, 2024
1 check passed
@github-actions github-actions bot mentioned this pull request Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants