Open cdoublev opened 10 months ago
Hm, the spec is indeed unclear here. I prefer Chrome's behavior - validating the initial-value
as normal for an untyped custom property. The spec just needs its conditions to be slightly rephrased to match.
To clarify my understanding:
initial-value: var(1)
makes the descriptor invalid and ignoredinitial-value: var(--initial)
makes the rule invalid because it is computationally dependentThat is, var(1)
is invalid at the syntax level of initial-value
, as specified:
If a property contains one or more
var()
functions, and those functions are syntactically valid, the entire property’s grammar must be assumed to be valid at parse time.
And initial-value: var(--initial)
is invalid at the context level of @property
, as specified:
- The
initial-value
must be computationally independent.If the above conditions are not met, the
@property
rule is invalid.
Computationally dependent values could have been specified as invalid at the context level of initial-value
, but this does not seem important since authors will probably not make multiple declarations of initial-value
.
So the specifications are already clear and I am closing this issue. I hope I am not missing something.
Indeed, I missed something. initial-value
must be computationally independent only when syntax
is *
.
initial-value
is technically a descriptor so var()
parsing should not be triggered as it is only for properties, and initial-value: var(1)
should be valid since var(1)
matches <declaration-value>
. This should also apply in CSS.registerProperty()
(WPT), unless:
initial-value
should be parsed as a propertyvar()
(and other arbitrary substitutions) should always have a valid syntax, even when used in another context than a property valueThis should then be explicitly specified in both cases.
But this is a different problem than a valid var()
. Please let me know if I should open a separate issue.
There are these lines on WPT (it is about the first and the third):
// initial-value: not computationally independent test_descriptor('initial-value', '3em', null, {'syntax': '"<length>"'}); test_descriptor('initial-value', 'var(--x)', null);
The spec requires initial-value
to be computationally independent for @property
to be valid, but only when syntax
is not *
.
An equivalent test exists for CSS.registerProperty()
. So I guess there is a good reason.
I wonder which one it is, and whether it also applies to other substitution functions like attr()
or first-valid()
.
If I understand the spec correctly,
initial-value
does not require to be validated whensyntax
is*
.But in Chrome, given the CSS rules below:
initial-value: var(1)
is discardedI am completely confused by the parse result in Chrome. Anyway, should
initial-value
be invalid when it includes an arbitrary substitution value?