Skip to content

[css-properties-and-values] Setting/registering is allowed to be order-dependent #354

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

Closed
tabatkins opened this issue Feb 3, 2017 · 2 comments

Comments

@tabatkins
Copy link
Member

Per Seattle resolution (resolution is badly worded, read up to figure out what was actually being discussed), we're OK with an order-dependence between setting a value and registering a value.

That is, we want the following behavior:

CSS.registerProperty("--foo", { grammar: "<color>" });
el.styleMap.set("--foo", "red");
el.styleMap.set("--foo", "hello"); // throws an error
// --foo is still set to "red"

and

el.styleMap.set("--foo", "red");
el.styleMap.set("--foo", "hello"); // valid at this point; --foo is untyped
CSS.registerProperty("--foo", { grammar: "<color>" }); // valid
// because --foo was set to a non-<color> value,
// it's now set to "unset", the bottom value for properties
@tabatkins
Copy link
Member Author

tabatkins commented Feb 3, 2017

Further clarification: per Seattle resolution, when using a typed property in a stylesheet, setting to an invalid value doesn't trigger fallback. That is:

<script>
CSS.registerProperty("--foo", {grammar: "<color>"});
</script>
<style>
div { --foo: red; }
div.foo {  --foo: hello; }
</style>

In here, the "--foo: hello" is not thrown out at parse-time; it's accepted, but because it's invalid, it gets treated as "--foo: unset;".

  • This is an intentional break from "real" CSS properties, because the threat model is different (unpredictable browsers with varying support, vs known libraries with well-known support).
  • This removes the order-dependence between setting and registration when you're setting in a stylesheet, rather than thru the JS API.
  • This makes typed custom properties less consistent with "real" CSS properties, but more consistent with untyped custom properties.

@shans
Copy link
Contributor

shans commented Apr 3, 2017

What specifically needs to change in Typed OM for this? Seems like mainly a properties & values thing?

jyc added a commit to jyc/css-houdini-drafts that referenced this issue Jul 19, 2017
…ntax-checked at computed-value time, not parse time.

Clarify that the `syntax` field is used during computed-value time,
write in the section about calculation of computed values that
declarations can be found invalid at computed-value time, and update the
example which previously indicated syntax-checking at parse time.

Per Seattle resolution, as expressed in the following comments:

> The original issue (should a property fail at parse-time if a typed
> custom property is used in a wrong way, per the property's grammar) is,
> I think, a no. I believe this falls out of our decision at the Seattle
> f2f (w3c#354) that registering a custom property shouldn't require an
> immediate global re-parse. You can do wrong things to/with a typed
> custom property; it'll just cause a failure at computed-value time, like
> an untyped custom property with an incompatible value does.
>
> - w3c#321 (comment)

> Further clarification: per Seattle resolution, when using a typed
> property in a stylesheet, setting to an invalid value doesn't trigger
> fallback ...
>
> - w3c#354 (comment)
jyc added a commit to jyc/css-houdini-drafts that referenced this issue Jul 19, 2017
…ntax-checked at computed-value time, not parse time.

Clarify that the `syntax` field is used during computed-value time,
write in the section about calculation of computed values that
declarations can be found invalid at computed-value time, and update the
example which previously indicated syntax-checking at parse time.

Per Seattle resolution, as expressed in the following comments:

> The original issue (should a property fail at parse-time if a typed
> custom property is used in a wrong way, per the property's grammar) is,
> I think, a no. I believe this falls out of our decision at the Seattle
> f2f (w3c#354) that registering a custom property shouldn't require an
> immediate global re-parse. You can do wrong things to/with a typed
> custom property; it'll just cause a failure at computed-value time, like
> an untyped custom property with an incompatible value does.
>
> - w3c#321 (comment)

> Further clarification: per Seattle resolution, when using a typed
> property in a stylesheet, setting to an invalid value doesn't trigger
> fallback ...
>
> - w3c#354 (comment)
@shans shans changed the title [css-typed-om] Setting/registering is allowed to be order-dependent [css-properties-and-values] Setting/registering is allowed to be order-dependent Oct 19, 2017
shans added a commit that referenced this issue Jul 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants