Repository navigation
Conversation
…exists Changing a watched non-prop attribute (e.g. `aria-label`) after a lazy component connected but before its module loaded threw, because `hostRef.$lazyInstance$` was still undefined. The change is now ignored, the same as a prop change before the instance exists. fixes: stenciljs#6945 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Open
3 tasks done
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the current behavior?
With the lazy loader, a component that uses
@Watchon a native (non-@Prop) attribute throws fromattributeChangedCallbackwhen that attribute changes after the element connects but before the component's module has loaded:The
propName == nullbranch only checkshostRef.$flags$, which already includeshasConnectedat that point, whilehostRef.$lazyInstance$is stillundefined.GitHub Issue Number: #6945
What is the new behavior?
The watcher lookup is null-safe (
instance?.[watchMethodName]), so a change that arrives before the instance exists is ignored. That matches@Propchanges, which don't fire watchers before the component is ready either. Changes after the instance exists still reach the watcher.Documentation
N/A
Does this introduce a breaking change?
Testing
newSpecPagetest insrc/runtime/test/watch.spec.tsx. It connects a component with@Watch('aria-label'), setsaria-labelbefore the module is flushed, and expects no error. AfterwaitForChanges()it sets the attribute again and expects the watcher to receive it.TypeError: Cannot read properties of undefined (reading 'ariaLabelChanged'). With the fix it passes.jest src/runtime: 65 suites, 684 tests pass.eslintandprettier --list-differentare clean on both files.wwwbuild of the component from bug: changing a watched native attribute before a lazy component's instance exists throws #6945. On 4.45.2 the page logs the uncaughtTypeError. Built against this branch, there is no error, and a latersetAttributelogsariaLabelChanged after load.Other information
We hit this in production through Ionic, where
ion-buttonwatchesaria-label,aria-pressedandaria-checkedand an Angular[attr.aria-label]binding can update the attribute before the button's chunk loads.🤖 Generated with Claude Code