-
Notifications
You must be signed in to change notification settings - Fork 795
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: can't access this
in form-associated callbacks
#5106
Labels
Bug: Validated
This PR or Issue is verified to be a bug within Stencil
Comments
2 tasks
The fix for this was included as a part of today's v4.8.1 release! |
alicewriteswrongs
added a commit
that referenced
this issue
Mar 14, 2024
If you need to write a wdio test which references a host element interface the test will not compile correctly, complaining that it can't resolve the interface. This problem was revealed while working on https://github.com/ionic-team/stencil/compare/ap/wdio/form-associated, where the component has a method like this: ```tsx formAssociatedCallback(form: HTMLFormAssociatedElement) { form.ariaLabel = 'formAssociated called'; // this is a regression test for #5106 which ensures that `this` is // resolved correctly this.internals.setValidity({}); } ``` The `HTMLFormAssociatedElement` interface is defined in `test/wdio/src/components.d.ts` and should be part of the global type namespace for the `test/wdio` project, but our `include/` in `test/wdio/tsconfig-stencil.json` wasn't including the component types correctly so that the interface wasn't being resolved.
github-merge-queue bot
pushed a commit
that referenced
this issue
Mar 14, 2024
…5470) If you need to write a wdio test which references a host element interface the test will not compile correctly, complaining that it can't resolve the interface. This problem was revealed while working on https://github.com/ionic-team/stencil/compare/ap/wdio/form-associated, where the component has a method like this: ```tsx formAssociatedCallback(form: HTMLFormAssociatedElement) { form.ariaLabel = 'formAssociated called'; // this is a regression test for #5106 which ensures that `this` is // resolved correctly this.internals.setValidity({}); } ``` The `HTMLFormAssociatedElement` interface is defined in `test/wdio/src/components.d.ts` and should be part of the global type namespace for the `test/wdio` project, but our `include/` in `test/wdio/tsconfig-stencil.json` wasn't including the component types correctly so that the interface wasn't being resolved.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prerequisites
Stencil Version
4.8.0
Current Behavior
In #4939 we added support for form-associated custom element lifecycle callbacks like
formAssociatedCallback
, however the way they're currently being called doesn't resolve the correctthis
value to ensure that properties on a Stencil component (e.g. ones decorated with@State
) can be resolved properly.So a little component like this one won't work correctly 😢:
Expected Behavior
If I try to access
this
in a method as in the example it should work correctly.System Info
No response
Steps to Reproduce
In any of the form-associated callbacks (e.g.
formAssociatedCallback
) try to access something onthis
, like a@State
property. You should get an error that it's not found (cannot read property 'so and so' of undefined). See the attached repro case.Code Reproduction URL
https://github.com/alicewriteswrongs/stencil-fa-cb-repro
Additional Information
No response
The text was updated successfully, but these errors were encountered: