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
[labs/react] Fix for #2799: add support for properties with custom accessors #2800
[labs/react] Fix for #2799: add support for properties with custom accessors #2800
Conversation
🦋 Changeset detectedLatest commit: 5c4eb26 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). For more information, open the CLA check for this pull request. |
@lideen thanks for identifying this and submitting a fix and tests! I made some comments on the implementation in the interest of speed here. I think the implementation can be collapsed into one I would like to also avoid materializing the property descriptors if possible. I think the core issue here is that accessors are not enumerable and |
012cce5
to
1531750
Compare
@justinfagnani Something like this? 1531750 |
@lideen that what I was thinking at the time (though with memoizing the function). But in the meantime I chatted with @josepharhar about it, and I think that we should match the Preact and upcoming React support for properties as much as possible. This would mean not pre-calculating the instance keys at all, but just using an |
1531750
to
79e6a4f
Compare
@justinfagnani I gave it a shot 79e6a4f. I removed the warning about reserved props as I don't think it fits well now when the check is done on-demand 🤔 . Let me know if I should re-add it. |
@justinfagnani sorry to ping you, but is there anything I can do to move this along? |
@lideen So sorry I missed that ping! I'm re-reviewing now. My main concern is how we verify that the behavior matches React 19, but we can address that over time. |
eventProps.has(k) || | ||
(!reservedReactProperties.has(k) && | ||
!(k in HTMLElement.prototype) && | ||
k in elementClass.prototype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We still need to verify this logic (specifically excluding k in HTMLElement.prototype
) with @josepharhar to see if it matches React 19. I'm good with going in as-is now though.
// would require crawling down the prototype, which doesn't feel worth | ||
// it since implementing these properties on an element is extremely | ||
// rare. | ||
console.warn( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should keep this warning. We can move this into a dev build in the future.
@lideen this has increased in urgency for us, so I'm going to try to see if I can get this in asap. Did you enable changes to your PR branch? https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork Edit: looks like I can push to your fork. Great! |
…-custom-accessors-bug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @lideen !
I'll follow up on the comments I left with issues.
Hi! All new to this repo but tried to fix a bug that I found #2799
Any input appreciated 🎉