-
Notifications
You must be signed in to change notification settings - Fork 252
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
click leads to endless loop for custom elements in label #1237
Comments
hmmmm, so after a bit of digging I found out that the following points hold true: 1.clicking on a 2.clicking on a custom element that qualifies as a labeled control does dispatch a click event, because it cannot be matched in the same way. This behaviour then re-dispatches a click event whose behaviour re-dispatches a click event and so on until the exception above is thrown. 3.the spec does not specify how user agents should behave sufficiently to warrant either way - dispatching the click event is allowed and not doing so is also allowed.
4.the spec does specify that a user agent should treat labelable elements the same.
So no matter what the user-agent decides is okay as long as both, CEs and builtins, are handled the same way. 5.while there are non-form-associated labelable elements there are no custom elements that are labelable but not form-associated. This means, as I read it, that the activation behaviour of form-associated custom elements can be left to the user-agent since they should be treated "the same" as other labeled controls. Which in turn means that the correct change imho would be this: - const control = context && isElementType(context, 'label') && context.control
+ const control = context && isElementType(context, 'label') && !(target.constructor as {formAssociated?: boolean}).formAssociated && context.control This way form-associated custom elements would also not have a defined click behaviour which prevents the endless loop. |
also relates to jsdom/jsdom#3790 |
Great report for a non-obvious bug. Thanks for contributing to this library 💙 |
🎉 This issue has been resolved in version 14.6.1 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Reproduction example
self contained html provided in prerequisites
Prerequisites
loading this throws the following error:
Expected behavior
Should not lead to endless loop
Actual behavior
leads to endless loop
User-event version
14.5.2
Environment
nope.
Additional context
I tried debugging it a bit and found that the PR #850 in which the closest label of a click target is selected and that is supposed to break the loop - I'm not sure how?
The text was updated successfully, but these errors were encountered: