fix: correctly call proxied formAssociated callbacks #6046
Merged
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.
Current Behavior
The
proxyComponent
function currently overwrites theformAssociatedCallback
and all otherformAssociated
-callback methods on the component’s prototype, causingthis.formAssociatedCallback
to reference the proxy wrapper instead of the original method. This results in infinite recursion when the method attempts to call itself.Note: This bug only occurs when the
externalRuntime
flag for thedist-custom-elements
output target is set tofalse
. In this configuration, the generated code does not use$lazyInstance$[cbName]
(which correctly references the original method) but instead relies onthis[cbName]
, which causes the method to recursively call itself, leading to an infinite loop.GitHub Issue: #6038
New Behavior
These changes ensure that
formAssociatedCallback
and all otherFORM_ASSOCIATED_CUSTOM_ELEMENT_CALLBACKS
are properly referenced and called, preventing infinite recursion. When thelazyLoad
flag is enabled, the method on the$lazyInstance$
is used. Otherwise, the original method is called directly, avoiding the infinite loop.Documentation
No significant documentation changes are required.
Breaking Change?
Testing
A new test has been added in test/wdio to verify this behavior.
Additional Information
None.