8000 [css-shadow-parts-1] Split out separate partmap attribute. Fixes #2468 · w3c/csswg-drafts@450d671 · GitHub
Skip to content

Commit 450d671

Browse files
committed
[css-shadow-parts-1] Split out separate partmap attribute. Fixes #2468
1 parent 82d7b52 commit 450d671

1 file changed

Lines changed: 41 additions & 26 deletions

File tree

css-shadow-parts-1/Overview.bs

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -119,27 +119,59 @@ it also helps with encapsulation,
119119
as authors can use ''::part()'' without fear of accidental over-styling.
120120

121121

122-
Exposing a Shadow Element: the <{html-global/part}> attribute {#part-attr}
122+
Exposing a Shadow Element: {#exposing}
123123
=============================================================
124+
Each <a>shadow root</a> has a <dfn export for="shadow root">shadow part map</dfn>
125+
which is an <a>ordered map</a>,
126+
with keys that are [=strings=]
127+
and values that are [=ordered sets=] of elements.
128+
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.
131+
132+
Issue: Factor this out into an algorithm.
133+
134+
Issue: The value in the map is a set of elements, not individual elements; need to properly append.
135+
136+
Naming a Shadow Element: the <{html-global/part}> attribute {#part-attr}
137+
------------------------------------------------------------------------
124138

125139
Any element in a shadow tree can have a <dfn element-attr for=html-global>part</dfn> attribute.
126-
This is used to expose the element outside the <a>shadow tree</a>,
127-
and to "forward" sub-parts of the element
128-
(if it has its own <a>shadow tree</a>)
129-
to outside the <a>shadow tree</a>.
140+
This is used to expose the element outside of the <a>shadow tree</a>.
130141

131-
The part attribute is parsed as a comma-separated list of part mappings.
132-
Each part mapping is one of:
142+
The part attribute is parsed as a space-separated list of part names.
143+
Each part name is:
133144

134145
<dl class=switch>
135146
: <code>ident</code>
136-
:: Adds «[ ident → el ]» to the <a>shadow part map</a> of the <a>shadow root</a> containing el.
147+
:: Adds «[ ident → el ]» to the <a>shadow part map</a> of the <a>shadow root</a> containing the element.
148+
149+
: anything else
150+
:: Ignored for error-recovery / future compat.
151+
</dl>
152+
153+
Note: It's okay to give a part multiple names.
154+
The "part name" should be considered similar to a class,
155+
not an id or tagname.
156+
157+
Forwarding a Shadow Element: the <{html-global/partmap}> attribute {#partmap-attr}
158+
----------------------------------------------------------------------------------
159+
Any element in a shadow tree can have a <dfn element-attr for=html-global>partmap</dfn> attribute.
160+
If the element is a shadow host,
161+
this is used to expose elements from inside this host's <a>shadow tree</a>< 10BC0 /span> to outside this host's containing <a>shadow tree</a>.
137162

163+
The partmap attribute is parsed as a comma-separated list of part mappings.
164+
Each part mapping is one of:
165+
166+
<dl class=switch>
138167
: <code>ident1 => ident2</code>
139168
:: If el is a <a>shadow host</a>,
140169
and it's <a>shadow root's</a> <a>shadow part map</a> |partMap| [=map/contains=] ident1,
141170
then this adds «[ ident2 → |partMap|[ident1] ]» to the <a>shadow part map</a> of the <a>shadow root</a> containing el.
142171

172+
: <code>ident</code>
173+
:: Is equivalent to <code>ident => ident</code>.
174+
143175
: <code>* => prefix*</code>
144176
:: If el is a <a>shadow host</a>,
145177
then [=map/for each=] |ident| → |subEl| in el's <a>shadow root's</a> <a>shadow part map</a>,
@@ -149,26 +181,9 @@ Each part mapping is one of:
149181
:: Ignored for error-recovery / future compat.
150182
</dl>
151183

152-
Issue: Factor this out into an algorithm.
153-
154-
Issue: The value in the map is a set of elements, not individual elements; need to properly append.
155-
156-
Issue: Want a way to forward a name with the same name, without repeating the name (currently requires `foo => foo`).
157-
158184
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`).
159185

160-
Note: It's okay to give a part multiple names,
161-
or map a sub-part to several names.
162-
The "part name" should be considered similar to a class,
163-
not an id or tagname.
164-
165-
Each <a>shadow root</a> has a <dfn export for="shadow root">shadow part map</dfn>
166-
which is an <a>ordered map</a>,
167-
with keys that are [=strings=]
168-
and values that are [=ordered sets=] of elements.
169-
170-
The <a>shadow part map</a> contains all the entries described by the elements in its <a>shadow tree</a>,
171-
as described above.
186+
Note: It's okay to map a sub-part to several names.
172187

173188
Exposing More Widely: the <{html-global/theme}> attribute {#theme-attr}
174189
-----------------------------------------------------------------------

0 commit comments

Comments
 (0)