-
Notifications
You must be signed in to change notification settings - Fork 792
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
bug: ref called in specified order and not after initializing element with all its attributes/properties #4074
Comments
Hi @jcfranco, thanks for reporting this issue! We have a few issues relating to Is it possible that this issue is reflective of the same underlying problem? By that I mean, those particular issues really can only be fixed by refactoring how Stencil's virtual DOM works to commit changes in an atomic way. We have plans to scope out and make that sort of fix in the future, but haven't been able to work it in to our plans just yet. Anywhooo - if you think that this is a separate issue we can for sure keep this issue open, but if it's a different symptom of the same underlying problem it might be good to add some of the information here on one of the other existing issues. Thanks again for filing and providing a reproduction case! I know that these |
@alicewriteswrongs Thanks for reply. 😄
I think this could remain open mainly because the referenced issues above have no context about the order of props/attributes affecting the |
Sure, we can leave this open for now. We do have plans to address these Thanks for filing! |
**Related Issue:** N/A ## Summary This updates `ref` usage to work around a [Stencil bug](ionic-team/stencil#4074) where the ref node can be out of sync. **Note**: this also updates the conventions doc with this info.
Sort attribute names before calling `setAccessor` with their changed values in order to ensure that the `ref` attribute is handled by `setAccessor` after all other attributes have been handled. This prevents the execution order for `ref` callbacks from being dependency on the order in which attributes are declared in the JSX. STENCIL-737 fixes #4074
Sort attribute names before calling `setAccessor` with their changed values in order to ensure that the `ref` attribute is handled by `setAccessor` after all other attributes have been handled. This prevents the execution order for `ref` callbacks from being dependency on the order in which attributes are declared in the JSX. STENCIL-737 fixes #4074
Sort attribute names before calling `setAccessor` with their changed values in order to ensure that the `ref` attribute is handled by `setAccessor` after all other attributes have been handled. This prevents the execution order for `ref` callbacks from being dependency on the order in which attributes are declared in the JSX. STENCIL-737 fixes #4074
The fix for this issue has been released as a part of today's Stencil v4.14.1 release. |
Prerequisites
Stencil Version
2.20.0/3.0.1
Current Behavior
The order of
ref
matters and can lead to props/attributes being outdated by the time the callback is invoked.Expected Behavior
ref
is called right after the element is fully initialized with all props/attributes. This aligns with other libraries that implement a similarref
mechanism (e.g., React, preact, maquette).System Info
Steps to Reproduce
Follow the steps to the repro case below.
Code Reproduction URL
https://github.com/jcfranco/stencil-ref-called-in-prop-order-instead-of-after-node-being-initialized
Additional Information
For comparison, I also created the following repro cases:
The text was updated successfully, but these errors were encountered: