@@ -1791,6 +1791,69 @@ Security</h4>
1791
1791
''--foo: attr(foo type(<number>)); background-image: src(string(var(--foo)))''
1792
1792
needs to be invalid as well.
1793
1793
1794
+ <h4 id=attr-cycles>
1795
+ Cycles</h4>
1796
+
1797
+ An attribute value may contain ''attr()'' functions,
1798
+ or other [=arbitrary substitution functions=] ,
1799
+ that are substituted during [=parse with a <syntax>=] .
1800
+ This can cause cyclic dependecies,
1801
+ either by an attribute referring to itself,
1802
+ through multiple attributes referring to each other,
1803
+ or through a combination of other [=arbitrary substitution functions=]
1804
+ (e.g. ''var()'' ).
1805
+
1806
+ For each element, add a node for every attribute on that element
1807
+ to the graph described in [[css-variables-1#cycles]] .
1808
+ Then, for each attribute <var> attrib</var> ,
1809
+ add edges as follows:
1810
+
1811
+ * From <var> attrib</var> to any attributes referenced by ''attr()''
1812
+ within <var> attrib</var> 's value.
1813
+ * From <var> attrib</var> to any [=custom properties=] referenced by ''var()''
1814
+ within <var> attrib</var> 's value.
1815
+ * From any [=custom property=] that references <var> attrib</var> using ''attr()''
1816
+ to <var> attrib</var> .
1817
+
1818
+ An ''attr()'' referencing an attribute
1819
+ which is part of a cycle
1820
+ makes the containing [=declaration=] [=invalid at computed-value time=] .
1821
+
1822
+ <div class='example'>
1823
+ In the following,
1824
+ <code> width</code> is [=invalid at computed-value time=] ,
1825
+ because ''attr()'' tries to substitute a value which refers to itself:
1826
+
1827
+ <pre class='lang-css'>
1828
+ div {
1829
+ width: attr(data-foo type(*));
1830
+ }
1831
+ </pre>
1832
+ <pre class='lang-html'>
1833
+ <div data-foo="attr(data-foo type(*))"></div>
1834
+ </pre>
1835
+
1836
+ Note: Even if one (or both) of the ''attr()'' functions had a fallback,
1837
+ the result would be the same.
1838
+ </div>
1839
+
1840
+ <div class='example'>
1841
+ Cycles can occur through [=custom properties=] ;
1842
+ in the following,
1843
+ <code> --x</code> and <code> --y</code> are both [=invalid at computed-value time=] :
1844
+
1845
+ <pre class='lang-css'>
1846
+ div {
1847
+ --x: var(--y);
1848
+ --y: attr(data-foo type(*));
1849
+ }
1850
+ </pre>
1851
+ <pre class='lang-html'>
1852
+ <div data-foo="var(--x)"></div>
1853
+ </pre>
1854
+ </div>
1855
+
1856
+
1794
1857
<!-- Big Text: random
1795
1858
1796
1859
████▌ ███▌ █ █▌ ████▌ ███▌ █ █
0 commit comments