Skip to content
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

Define :user-valid and :user-invalid pseudo-classes #8452

Closed
annevk opened this issue Oct 28, 2022 · 5 comments · Fixed by #9047
Closed

Define :user-valid and :user-invalid pseudo-classes #8452

annevk opened this issue Oct 28, 2022 · 5 comments · Fixed by #9047

Comments

@annevk
Copy link
Member

annevk commented Oct 28, 2022

User agents are implementing :user-valid and :user-invalid pseudo-classes, but it seems these are not yet defined in HTML so there's some potential for issues with them.

cc @whatwg/css

@domenic
Copy link
Member

domenic commented Nov 10, 2022

Note some discussion at web-platform-tests/interop#178 (comment)

@nt1m
Copy link
Member

nt1m commented Dec 16, 2022

My implementation in WebKit/WebKit#7730 is matching the :user-* pseudos between the last user-initiated form submission (if any) and the last user-initiated change event. If there isn't a user-initiated change event, the pseudos do not match.

User-initiated form submissions acts like a "reset" for the pseudo-class as the CSS spec defines: https://w3c.github.io/csswg-drafts/selectors/#user-pseudos

From an user-POV this seems to match FF's behavior, though I haven't looked deeply into how it works. cc @emilio

Can we spec it that way?

@annevk
Copy link
Member Author

annevk commented Dec 16, 2022

Thanks, that helps, but I have some more questions.

Should requestSubmit() count as a "user" submit? What if you do click() on a submit button? Or are we adding a "user activated" check for this somewhere? Form submission doesn't have that currently except if the target is a new window. And at what point in the form submission algorithm does it start counting? (As in, ideally we identify how to modify the form submission algorithm to set that bit of state.)

@nt1m
Copy link
Member

nt1m commented Dec 16, 2022

I use UserGestureIndicator::processingUserGesture() which matches anything that comes from the an user gesture (keypress, click) and that happens in the same run-loop as that user gesture (e.g. any submission done async won't match).

Perhaps a better a model would be to just make every form submission reset the state. (I haven't dived too deeply into what FF does)

@nt1m
Copy link
Member

nt1m commented Mar 16, 2023

I have a rough vision of how to spec user-valid and invalid

nt1m added a commit to nt1m/html that referenced this issue Mar 17, 2023
nt1m added a commit to nt1m/html that referenced this issue Mar 30, 2023
nt1m added a commit to nt1m/html that referenced this issue Mar 30, 2023
nt1m added a commit to nt1m/html that referenced this issue Mar 31, 2023
nt1m added a commit to nt1m/html that referenced this issue Aug 7, 2023
nt1m added a commit to nt1m/html that referenced this issue Aug 7, 2023
nt1m added a commit to nt1m/html that referenced this issue Aug 8, 2023
nt1m added a commit to nt1m/html that referenced this issue Aug 8, 2023
nt1m added a commit to nt1m/html that referenced this issue Aug 18, 2023
nt1m added a commit to nt1m/html that referenced this issue Aug 18, 2023
annevk added a commit that referenced this issue Aug 28, 2023
Better integration for custom elements will be handled by #9639.

Fixes #8452.

Co-authored-by: Domenic Denicola <d@domenic.me>
Co-authored-by: Anne van Kesteren <annevk@annevk.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants