Bug 266455 - :user-invalid and :user-valid do not trigger for Form Associated Custom Elements
Summary: :user-invalid and :user-valid do not trigger for Form Associated Custom Elements
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: Safari 17
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-12-14 20:47 PST by Nathan Knowler
Modified: 2023-12-21 20:48 PST (History)
2 users (show)

See Also:


Attachments
Demonstration of :user-invalid and :user-valid with a form associated custom element (works in Firefox) (2.51 KB, text/html)
2023-12-14 20:47 PST, Nathan Knowler
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Nathan Knowler 2023-12-14 20:47:26 PST
Created attachment 469055 [details]
Demonstration of :user-invalid and :user-valid with a form associated custom element (works in Firefox)

`:user-invalid` and `:user-valid` do not work for form associated custom elements in Safari (or Chrome). It does work correctly in Firefox. I am able to trigger those pseudo-classes for a form associated custom element in Firefox when I make the form value of the element dirty with `ElementInternals.setFormValue()`, then either by setting or clearing a constraint violation with `ElementInternals.setValidity()`.
Comment 1 Nathan Knowler 2023-12-14 21:09:04 PST
Chromium issue is here: https://bugs.chromium.org/p/chromium/issues/detail?id=1511887
Comment 2 Tim Nguyen (:ntim) 2023-12-14 21:20:20 PST
It's not supposed to trigger for form associated custom elements according to the spec:

https://html.spec.whatwg.org/#selector-user-valid

There is a spec issue to change that though: https://github.com/whatwg/html/issues/9639

Firefox's implementation pre-dates the official specification for :user-valid/invalid.
Comment 3 Radar WebKit Bug Importer 2023-12-21 20:48:14 PST
<rdar://problem/120027003>