@@ -109,7 +109,16 @@ from the sub-parts that it merely happens to contain,
109
109
it also helps with encapsulation,
110
110
as authors can use ''::part()'' without fear of accidental over-styling.
111
111
112
-
112
+ <!-- Big Text: parts
113
+
114
+ ████▌ ███▌ ████▌ █████▌ ███▌
115
+ █▌ █▌ ▐█ ▐█ █▌ █▌ █▌ █▌ █▌
116
+ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌
117
+ ████▌ █▌ █▌ ████▌ █▌ ███▌
118
+ █▌ █████▌ █▌▐█ █▌ █▌
119
+ █▌ █▌ █▌ █▌ ▐█ █▌ █▌ █▌
120
+ █▌ █▌ █▌ █▌ █▌ █▌ ███▌
121
+ -->
113
122
Exposing a Shadow Element: {#exposing}
114
123
=============================================================
115
124
Elements in a <a>shadow tree</a> may be exported for styling by stylesheets outside the tree
@@ -146,12 +155,25 @@ and changes to the [=part name lists=] and [=forwarded part name lists=] of elem
146
155
then let |innerRoot| be its shadow root.
147
156
3. [=calculate the part element map|Calculate=] |innerRoot|'s [=part element map=] .
148
157
4. For each |innerName|/|outerName| in |el|'s [=forwarded part name list=] :
149
- 1. Let |innerParts| be |innerRoot|'s [=part element map=] [|innerName|]
150
- 2. [=list/Append=] the elements in |innerParts|
151
- to |outerRoot|'s [=part element map=] [|outerName|]
158
+ 1. If |innerName| is an ident:
159
+ 1. Let |innerParts| be |innerRoot|'s [=part element map=] [|innerName|]
160
+ 2. [=list/Append=] the elements in |innerParts|
161
+ to |outerRoot|'s [=part element map=] [|outerName|]
162
+ 2. If |innerName| is a pseudo-element name:
163
+ 1. [=list/Append=] |innerRoot|'s pseudo-element(s) with that name
164
+ to |outerRoot|'s [=part element map=] [|outerName|] .
152
165
</div>
153
166
167
+ <!-- Big Text: part=""
154
168
169
+ ████▌ ███▌ ████▌ █████▌ ▐█▌ ▐█▌ ▐█▌ ▐█▌
170
+ █▌ █▌ ▐█ ▐█ █▌ █▌ █▌ ▐█▌ ▐█▌ ▐█▌ ▐█▌
171
+ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ████ █ █ █ █
172
+ ████▌ █▌ █▌ ████▌ █▌
173
+ █▌ █████▌ █▌▐█ █▌ ████
174
+ █▌ █▌ █▌ █▌ ▐█ █▌
175
+ █▌ █▌ █▌ █▌ █▌ █▌
176
+ -->
155
177
Naming a Shadow Element: the <{html-global/part}> attribute {#part-attr}
156
178
------------------------------------------------------------------------
157
179
@@ -179,6 +201,16 @@ not an id or tagname.
179
201
</script>
180
202
</pre>
181
203
204
+ <!-- Big Text: exportparts
205
+
206
+ █████▌ █ █ ████▌ ███▌ ████▌ █████▌ ████▌ ███▌ ████▌ █████▌ ███▌
207
+ █▌ █ █ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐█ ▐█ █▌ █▌ █▌ █▌ █▌
208
+ █▌ █ █ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌
209
+ ████ █ ████▌ █▌ █▌ ████▌ █▌ ████▌ █▌ █▌ ████▌ █▌ ███▌
210
+ █▌ █ █ █▌ █▌ █▌ █▌▐█ █▌ █▌ █████▌ █▌▐█ █▌ █▌
211
+ █▌ █ █ █▌ █▌ █▌ █▌ ▐█ █▌ █▌ █▌ █▌ █▌ ▐█ █▌ █▌ █▌
212
+ █████▌ █ █ █▌ ███▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ███▌
213
+ -->
182
214
Forwarding a Shadow Element: the <{html-global/exportparts}> attribute {#exportparts-attr}
183
215
----------------------------------------------------------------------------------
184
216
Any element in a shadow tree can have a <dfn element-attr for=html-global>exportparts</dfn> attribute.
@@ -200,6 +232,12 @@ Each part mapping is one of:
200
232
201
233
Note: This is shorthand for <code> ident : ident</code> .
202
234
235
+ : <code> ::ident : outerIdent</code>
236
+ :: If <code> ::ident</code> is the name of a [=part-like pseudo-element=] ,
237
+ adds <code> ::ident</code> /<code> outerIdent</code>
238
+ to el's [=forward part name list=] .
239
+ Otherwise, does nothing.
240
+
203
241
: anything else
204
242
:: Ignored for error-recovery / future compatibility.
205
243
</dl>
@@ -235,8 +273,40 @@ Note: It's okay to map a sub-part to several names.
235
273
</script>
236
274
</pre>
237
275
276
+ <div class=example>
277
+ For example, a [=part-like pseudo-element=]
278
+ can be used in the <{html-global/exportparts}> attribute,
279
+ to masquerade as a ''::part()''
280
+ for the component it's in:
281
+
282
+ <xmp class=html>
283
+ <template id=custom-element-template>
284
+ <p exportparts="::before : preceding-text, ::after : following-text">
285
+ Main text.
286
+ </template>
287
+ </xmp>
288
+
289
+ An element using that template
290
+ can use a selector like ''x-component::part(preceding-text)''
291
+ to target the ''p::before'' pseudo-element in its shadow,
292
+ so users of the component don't need to know
293
+ that the preceding text is implemented as a pseudo-element.
294
+ </div>
295
+
296
+
297
+ <!-- Big Text: ::part()
298
+
299
+ █▌ █▌ ████▌ ███▌ ████▌ █████▌ ██ ██
300
+ ███▌ ███▌ █▌ █▌ ▐█ ▐█ █▌ █▌ █▌ █▌ ▐█
301
+ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐█
302
+ ████▌ █▌ █▌ ████▌ █▌ █▌ ▐█
303
+ █▌ █▌ █▌ █████▌ █▌▐█ █▌ █▌ ▐█
304
+ ███▌ ███▌ █▌ █▌ █▌ █▌ ▐█ █▌ █▌ ▐█
305
+ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ██ ██
306
+ -->
307
+
238
308
Selecting a Shadow Element: the ''::part()'' pseudo-element {#part}
239
- ============================================================================================
309
+ ===================================================================
240
310
241
311
The <dfn selector>::part()</dfn> pseudo-element
242
312
allows you to select elements that have been exposed via a <{html-global/part}> attribute.
@@ -248,18 +318,14 @@ The syntax is:
248
318
249
319
The ''::part()'' pseudo-element only matches anything
250
320
when the <a>originating element</a> is a <a>shadow host</a> .
251
- If the <a>originating element's</a> <a>shadow root's</a> <a>part element map</a>
252
- [=map/contains=] all of the specified <<ident>> s,
253
- ''::part()'' matches the element or elements keyed to that <<ident>> .
254
- Otherwise, it matches nothing.
255
321
256
322
<div class="example">
257
323
For example,
258
324
if you have a custom button
259
325
that contains a "label" element that is exposed for styling
260
326
(via <code> part="label"</code> ),
261
327
you can select it with
262
- ''#the -button::part(label)'' .
328
+ ''x -button::part(label)'' .
263
329
</div>
264
330
265
331
<div class="example">
@@ -277,15 +343,16 @@ Otherwise, it matches nothing.
277
343
(or ''::part(active tab)'' , as order doesn't matter).
278
344
</div>
279
345
280
- The ''::part()'' pseudo-element can take additional pseudo-classes after it,
281
- such as ''x-button::part(label):hover'' ,
282
- but never matches the <a>structural pseudo-classes</a>
283
- or any other pseudo-classes that match based on tree information
284
- rather than local element information.
346
+ The ''::part()'' pseudo-element is a [=part-like pseudo-element=] .
347
+ If the <a>originating element's</a> <a>shadow root's</a> <a>part element map</a>
348
+ [=map/contains=] the specified <<ident>> ,
349
+ ''::part()'' represents the elements keyed to that ident;
350
+ if multiple idents are provided and the [=part element map=] contains them all,
351
+ it represents the intersection of the elements keyed to each ident.
352
+ Otherwise, it matches nothing.
285
353
286
- The ''::part()'' pseudo-element can also take additional pseudo-elements after it,
287
- such as ''x-button::part(label)::before'' ,
288
- but never match additional ''::part()'' s.
354
+ ''::part()'' pseudo-elements inherit according to their position
355
+ in the [=originating element's=] shadow tree.
289
356
290
357
<div class=example>
291
358
For example,
@@ -303,6 +370,18 @@ but never match additional ''::part()''s.
303
370
ignoring any other labels.
304
371
</div>
305
372
373
+
374
+ <!-- Big Text: CSSOM
375
+
376
+ ███▌ ███▌ ███▌ ███▌ █ █
377
+ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ██ ██
378
+ █▌ █▌ █▌ █▌ █▌ █▌█ █▐█
379
+ █▌ ███▌ ███▌ █▌ █▌ █▌ █ ▐█
380
+ █▌ █▌ █▌ █▌ █▌ █▌ ▐█
381
+ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ █▌ ▐█
382
+ ███▌ ███▌ ███▌ ███▌ █▌ ▐█
383
+ -->
384
+
306
385
Extensions to the {{Element}} Interface {#idl}
307
386
==============================================
308
387
0 commit comments