-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add an API for the internal CustomStateSet
#18
Comments
For what it's worth, this can be recreated by doing <meta property="isChecked">
<script>
effect(() => {
if($.isChecked) internals.states.add('is-checked')
else internals.states.delete('is-checked')
}, update => update())
</script> but this is a little more verbose than I'd like (especially for something that should be simple), and it is not self-documenting like e.g. |
Potential issue; it is not currently possible to sync the items in |
Also, another issue; states are not always boolean. Sometimes you'll want e.g. |
Could also be an option to define different sets of states that are then mutually exclusive, like <meta state="visible, hidden" as="visibility">
<meta state="red, green, blue" as="color"> But this is rather hard to parse (i.e. takes a considerable amount of code and is relatively non-generic) and still does not cater for more complex situations. For example, having |
It's be cool if authors could use e.g.
then component users can use
:state(is-checked)
and.isChecked
for component state. This essentially just creates theisChecked
property (a boolean), and is linked to whether or not theCustomStateSet
includes the stringis-checked
. Probably also thereadonly
attribute should be supported, because authors might not always want to allow component users to modify internal state. Potentially alsoas
should be optional, though it's a tad unclear to me as of now what the expected behavior would be; would the property be omitted altogether or would the created property name match the camelCasedstate
name?See
CustomStateSet
on MDN. This is relatively widely supported, only Safari is lagging behind even withElementInternals
.The text was updated successfully, but these errors were encountered: