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
Each <a>shadow root</a> has a <dfn export for="shadow root">shadow part map</dfn>
121
+
Elements in a <a>shadow tree</a> may be exposed for styling by stylesheets outside the tree
122
+
using the part and partmap attributes.
123
+
124
+
Each element has a <dfn export for="element">part name list</dfn>
125
+
which is an [=ordered sets=] of tokens.
126
+
127
+
Each element has a <dfn export for="element">part name map</dfn>
125
128
which is an <a>ordered map</a>,
129
+
with keys that are tokens
130
+
and values that are [=ordered sets=] of tokens.
131
+
132
+
Each <a>shadow root</a> can be thought of as having a <dfn export for="shadow root">part element map</dfn>
126
133
with keys that are [=strings=]
127
134
and values that are [=ordered sets=] of elements.
128
135
129
-
The <a>shadow part map</a> contains all the entries named or forwarded by the elements in its <a>shadow tree</a>,
130
-
as described below.
136
+
The part element map is described
137
+
only as part of the algorithm for calculating style in this spec.
138
+
It is not exposed via the DOM,
139
+
as calculating it may be expensive
140
+
and exposing it could allow access to elements inside closed shadow roots.
141
+
142
+
Part element maps are affected by the addition and removal of elements
143
+
and changes to the part name lists and part name maps of elements in the DOM.
144
+
145
+
To calculate the part element map of a shadow root, |r|:
146
+
147
+
<ol>
148
+
<li>For each element, |el| within |r|
149
+
<ol>
150
+
<li>For each |name| in |el|'s part name list,
151
+
add |el| to |r|'s part element map
152
+
under the key |name|.
153
+
<li>If |el| is a shadow host itself, let |er| be its shadow root:
154
+
<ol>
155
+
<li>Calculate |er|'s part element map.
156
+
<li>For each key, |outerName|, in |r|'s part name map
157
+
and for each token |innerName| under that key
158
+
look up |innerName| in |er|'s shadow part element map
159
+
to get a (possibly empty) set of elements
160
+
and add these elements to |r|'s part element map under |outerName|
161
+
</ol>
162
+
</ol>
163
+
</ol>
164
+
165
+
166
+
Issue: Include wild-card forwarding in algortihm.
131
167
132
-
Issue: Factor this out into an algorithm.
168
+
Issue: When doing prefixed-wildcard forwarding, should probably automatically exclude sub-parts that are manually forwarded. With that, would be good to have a syntax to block forwarding of a sub-part (currently would require `foo => nonsense-name`).
133
169
134
-
Issue: The value in the map is a set of elements, not individual elements; need to properly append.
170
+
Issue: There is no need for the part element map values to be ordered, can we drop that?
135
171
136
172
Naming a Shadow Element: the <{html-global/part}> attribute {#part-attr}
Any element in a shadow tree can have a <dfn element-attr for=html-global>partmap</dfn> attribute.
160
187
If the element is a shadow host,
161
-
this is used to expose elements from inside this host's <a>shadow tree</a> to outside this host's containing <a>shadow tree</a>.
188
+
this is used to allow styling of parts from hosts inside the <a>shadow tree</a>
189
+
by rules outside this the <a>shadow tree</a>
190
+
(as if they were elements in the same tree as the host,
191
+
named by a part attribute).
162
192
163
193
The partmap attribute is parsed as a comma-separated list of part mappings.
164
194
Each part mapping is one of:
165
195
166
196
<dl class=switch>
167
-
: <code>ident1 => ident2</code>
168
-
:: If el is a <a>shadow host</a>,
169
-
and it's <a>shadow root's</a><a>shadow part map</a> |partMap| [=map/contains=] ident1,
170
-
then this adds «[ ident2 → |partMap|[ident1] ]» to the <a>shadow part map</a> of the <a>shadow root</a> containing el.
197
+
: <code>outerIdent => innerIdent</code>
198
+
:: this adds «[ outerIdent → innerIdent ]» to el's <a>part name map</a>.
171
199
172
200
: <code>ident</code>
173
201
:: Is equivalent to <code>ident => ident</code>.
174
202
175
-
: <code>* => prefix*</code>
176
-
:: If el is a <a>shadow host</a>,
177
-
then [=map/for each=] |ident| → |subEl| in el's <a>shadow root's</a><a>shadow part map</a>,
178
-
«[ prefix + |ident| → |subEl| ]» is added to the <a>shadow part map</a> of the <a>shadow root</a> containing el.
179
-
180
203
: anything else
181
204
:: Ignored for error-recovery / future compat.
182
205
</dl>
183
206
184
-
Issue: When doing prefixed-wildcard forwarding, should probably automatically exclude sub-parts that are manually forwarded. With that, would be good to have a syntax to block forwarding of a sub-part (currently would require `foo => nonsense-name`).
185
-
186
207
Note: It's okay to map a sub-part to several names.
187
208
209
+
Issue: Decide whether we use "outer => inner" or vice-versa.
210
+
211
+
Issue: Decide whether to allow "ident1 => ident2 ident3 ..."
212
+
as shorthand for "ident1 => ident2, ident1 => ident3, ...".
213
+
188
214
Exposing More Widely: the <{html-global/theme}> attribute {#theme-attr}
0 commit comments