Skip to content

Commit 0d4545d

Browse files
committed
[css-shadow-parts] Switch ::theme() to keying off of a theme='' attribute. Fixes w3c#1972.
1 parent 12d4802 commit 0d4545d

1 file changed

Lines changed: 27 additions & 12 deletions

File tree

css-shadow-parts/Overview.bs

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ Abstract: This specification defines the ''::part()'' and ''::theme()'' pseudo-e
1313
<pre class=link-defaults>
1414
spec:selectors-4;
1515
type:selector; text::hover
16-
type:dfn; text:dynamic profile
16+
type:dfn; text:live profile
1717
type:dfn; text:structural pseudo-class
1818
spec:dom; type:dfn; for:/; text:shadow root
19+
spec:infra;
20+
type:dfn; text:string
1921
</pre>
2022

2123
Introduction {#intro}
@@ -62,7 +64,7 @@ it exposed too much of a component's internal structure to scrutiny,
6264
defeating some of the encapsulation benefits that using Shadow DOM brings.
6365
For this,
6466
and other performance-related reasons,
65-
the >>> combinator was eventually removed from the <a>dynamic profile</a>.
67+
the >>> combinator was eventually removed from the <a>live profile</a>.
6668

6769
This left us with using <a>custom properties</a> as the only way to style into a shadow tree:
6870
the component would advertise that it uses certain <a>custom properties</a> to style its internals,
@@ -112,7 +114,7 @@ for something authors can already do with <a>custom properties</a>.
112114
By separating out the explicitly "published" parts of an element
113115
(the <a>shadow part map</a>
114116
from the sub-parts that it merely happens to contain
115-
(the <a>shadow theme map</a>,
117+
(the <a>computed shadow theme map</a>,
116118
it also helps with encapsulation,
117119
as authors can use ''::part()'' without fear of accidental over-styling.
118120

@@ -153,20 +155,33 @@ The "part name" should be considered similar to a class,
153155
not an id or tagname.
154156

155157
Each <a>shadow root</a> has a <dfn export for="shadow root">shadow part map</dfn>
156-
and a <dfn export for="shadow root">shadow theme map</dfn>,
157-
both of which are <a>ordered maps</a>.
158+
which is an <a>ordered map</a>,
159+
with keys that are [=strings=]
160+
and values that are [=ordered sets=] of elements.
158161

159162
The <a>shadow part map</a> contains all the entries described by the elements in its <a>shadow tree</a>,
160163
as described above.
161164

162-
If the <a>shadow root</a>'s {{ShadowRoot/mode}} is {{ShadowRootMode/"closed"}},
163-
the <a>shadow theme map</a> is identical to the <a>shadow part map</a>.
165+
Exposing More Widely: the <{html-global/theme}> attribute {#theme-attr}
166+
-----------------------------------------------------------------------
167+
168+
In addition to the [=shadow part map=],
169+
every [=shadow root=] has a <dfn export for="shadow root">partial shadow theme map</dfn>
170+
and a <dfn export for="shadow root">computed shadow theme map</dfn>
171+
both of which are [=ordered maps=]
172+
(with the same key/value shape as the [=shadow part map=]),
173+
and the elements in the [=shadow tree=]
174+
have a corresponding <dfn element-attr for=html-global>theme</dfn> attribute.
175+
176+
The <{html-global/theme}> attribute is parsed and interpreted identically to the <{html-global/part}> attribute,
177+
except that it adds its entries to the [=shadow root’s=] [=partial shadow theme map=] instead.
178+
179+
If the [=shadow root’s=] {{ShadowRoot/mode}} is {{ShadowRootMode/"closed"}},
180+
the [=computed shadow theme map=] is identical to the [=partial shadow theme map=].
164181
Otherwise,
165-
it's the concatenation of the <a>shadow part map</a>
166-
with the <a>shadow theme maps</a> of every <a>shadow host</a>'s <a>shadow root</a> in its <a>shadow tree</a>.
182+
it's the union of the [=partial shadow theme map=]
183+
with the [=computed shadow theme maps=] of every [=shadow host’s=] [=shadow root=] in its [=shadow tree=].
167184

168-
Issue: TODO: Define a syntax or new attribute
169-
to prevent an element from adding things to its <a>shadow root's</a> <a>shadow theme map</a>.
170185

171186
Selecting a Shadow Element: the ''::part()'' and ''::theme()'' pseudo-elements {#part-theme}
172187
============================================================================================
@@ -201,7 +216,7 @@ The ''::theme()'' pseudo-element is similar,
201216
except it can match regardless of whether the <a>originating element</a>
202217
is a <a>shadow host</a> or not.
203218
It matches the elements keyed to the specified <<ident>>
204-
in the <a>shadow theme map</a> of the <a>shadow trees</a>
219+
in the <a>computed shadow theme map</a> of the <a>shadow trees</a>
205220
of the <a>originating element</a> or any descendants.
206221

207222
<div class="example">

0 commit comments

Comments
 (0)