You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In #7523 (comment) we resolved to adopt a comma-separated syntax for <custom-property-name> to support registering multiple properties that share the same descriptors in one go.
However, we do not seem to have consensus on the best CSSOM to represent this.
Opening this so we can discuss without clobbering the shorthand syntax discussed in #7523, though the design should also take it into account.
Discussion
Requirements
Existing single-name @property rules MUST produce the same CSSOM
CSSPropertyRule.prototype.name is read-only so we don't need to answer the question "how does the setter behave?". That said, it would be nice if the design did not actively get in the way of making it writable later.
Options
Option 1: Expand to multiple CSSPropertyRule rules at parse time
No CSSPropertyRule changes. The rule just expands to multiple CSSPropertyRule rules at parse time.
Pros:
No CSSOM changes
Supports almost any future syntax
Authors don't need to parse any microsyntax
Backwards compatible with existing consumers
Cons:
No roundtripping
Making name writable later would be hard
insertRule() can insert multiple rules, which is weird
Option 2: name/names
This includes:
name includes the full comma-separated list, no other change
name includes the full comma-separated list, names as a FrozenArray
name is empty when multiple names, names as a FrozenArray
Pros:
Serialization roundtrips
Cons:
All of these special case the name fanout, unclear how this expands to the syntax shorthand. In theory we could add plural versions of all descriptors as shorthands are added (syntaxes etc), but we need to keep multiple arrays in sync, which is awkward
For 2.1: Authors need to do their own parsing, which will get even more complex with the shorthand expansions
Option 3: Nested CSSPropertyRule
CSSPropertyRule gains a cssRules property which is a CSSPropertyRule[]. Its properties represent base values as specified in the actual rule, but child rules can override them.
Single-property usage is backwards compatible, consumers need to be updated to read multi-property rules correctly.
Pros:
Most faithful representation, objects correspond exactly to what was written
Roundtrips correctly
Scales better to future syntax extensions like shorthand types, nesting etc
Even supports a future writable name — it would just generate cssRules.
Cons:
Biggest lift, incompatible with code consuming the existing schema
Requires additional design decisions for every single descriptor on the root object
What would name be? Empty? A comma-separated list? The first name?
What would syntax be once we have the shorthand syntax? Empty? A union of all? The first one?
etc
I’m moderately strongly against 2, but I'm fine with 1 or 3.
I originally recommended 1 as I think it would be unfortunate to gate this feature on a big CSSOM change, but 3 is the "proper" way, and can scale to cover a lot of future expansion.
In #7523 (comment) we resolved to adopt a comma-separated syntax for
<custom-property-name>to support registering multiple properties that share the same descriptors in one go.However, we do not seem to have consensus on the best CSSOM to represent this.
Opening this so we can discuss without clobbering the shorthand syntax discussed in #7523, though the design should also take it into account.
Discussion
Requirements
@propertyrules MUST produce the same CSSOMnameonly (e.g.CSSPropertyRule.prototype.names) will have trouble once the shorthandsyntaxsyntax is introduced ([css-properties-values-api] Shorthand for custom property declaration #7523)Nice to haves
CSSPropertyRule.prototype.nameis read-only so we don't need to answer the question "how does the setter behave?". That said, it would be nice if the design did not actively get in the way of making it writable later.Options
Option 1: Expand to multiple
CSSPropertyRulerules at parse timeNo
CSSPropertyRulechanges. The rule just expands to multipleCSSPropertyRulerules at parse time.Pros:
Cons:
namewritable later would be hardinsertRule()can insert multiple rules, which is weirdOption 2:
name/namesThis includes:
nameincludes the full comma-separated list, no other changenameincludes the full comma-separated list,namesas aFrozenArraynameis empty when multiple names,namesas aFrozenArrayPros:
Cons:
syntaxshorthand. In theory we could add plural versions of all descriptors as shorthands are added (syntaxesetc), but we need to keep multiple arrays in sync, which is awkwardOption 3: Nested
CSSPropertyRuleCSSPropertyRulegains acssRulesproperty which is aCSSPropertyRule[]. Its properties represent base values as specified in the actual rule, but child rules can override them.Single-property usage is backwards compatible, consumers need to be updated to read multi-property rules correctly.
Pros:
name— it would just generatecssRules.Cons:
namebe? Empty? A comma-separated list? The first name?syntaxbe once we have the shorthand syntax? Empty? A union of all? The first one?I’m moderately strongly against 2, but I'm fine with 1 or 3.
I originally recommended 1 as I think it would be unfortunate to gate this feature on a big CSSOM change, but 3 is the "proper" way, and can scale to cover a lot of future expansion.