Skip to content

Commit d321ece

Browse files
andruudtabatkins
authored andcommitted
[css-properties-values-api] Describe font-relative unit cycles. (#777)
See #315.
1 parent 8e32d08 commit d321ece

File tree

1 file changed

+46
-1
lines changed

1 file changed

+46
-1
lines changed

css-properties-values-api/Overview.bs

+46-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ following members:
100100
:: The initial value of this custom property.
101101

102102
The {{registerProperty()}} function {#the-registerproperty-function}
103-
--------------------------------------------------------------------------------------------------
103+
--------------------------------------------------------------------
104104

105105
The <dfn method for=CSS>registerProperty(PropertyDescriptor descriptor)</dfn> method
106106
registers a custom property according to the configuration options provided in
@@ -458,7 +458,52 @@ but be automatically [=invalid at computed-value time=].
458458
As ''@supports'' tests parse behavior,
459459
it thus also accepts all values as valid regardless of the registered syntax.
460460

461+
Dependency cycles via relative units
462+
------------------------------------
463+
464+
Registered custom properties follow the same rules for dependency cycle
465+
resolution as unregistered custom properties, with the following additional
466+
constraints:
467+
468+
For any registered custom property with a <<length>> or <<length-percentage>> syntax
469+
component:
470+
471+
* If the property contains any of the following units:
472+
''em'', ''ex'', ''cap'', ''ch'', ''ic'', ''lh'';
473+
then add an edge between the property and the ''font-size'' of the current
474+
element.
475+
* If the property contains the ''lh'' unit,
476+
add an edge between the property and the ''line-height'' of the current
477+
element.
478+
* If the property contains any of the following units: ''rem'', ''rlh'';
479+
then add an edge between the property
480+
and the 'font-size'' of the root element.
481+
* If the property contains the 'rlh' unit, add an edge between the property
482+
and the 'line-height'' of the root element.
461483

484+
<div class='example'>
485+
For example, given this registration:
486+
487+
<pre class='lang-javascript'>
488+
CSS.registerProperty({
489+
name: "--my-font-size",
490+
syntax: "&lt;length>",
491+
initialValue: "0px",
492+
inherits: false
493+
});
494+
</pre>
495+
496+
the following will produce a dependency cycle:
497+
498+
<pre class='lang-css'>
499+
div {
500+
--my-font-size: 10em;
501+
font-size: var(--my-font-size);
502+
}
503+
</pre>
504+
505+
and ''font-size'' will behave as if the value ''unset'' was specified.
506+
</div>
462507

463508
Behavior of Custom Properties {#behavior-of-custom-properties}
464509
==============================================================

0 commit comments

Comments
 (0)