Skip to content

Commit 0934093

Browse files
committed
[css-shadow-parts-1] Rename 'part name map' to 'forwarded part name list' and switch its data model to a list of pairs for easier understanding. Link more terms. Restructure the 'part element list' algo a bit, shouldn't be a normative change.
1 parent ba1b24f commit 0934093

1 file changed

Lines changed: 26 additions & 32 deletions

File tree

css-shadow-parts-1/Overview.bs

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -118,46 +118,38 @@ using the part and exportparts attributes.
118118
Each element has a <dfn export for="element">part name list</dfn>
119119
which is an [=ordered set=] of tokens.
120120

121-
Each element has a <dfn export for="element">part name map</dfn>
122-
which is an <a>ordered map</a>,
123-
with keys that are [=strings=]
124-
(part names to expose to selectors outside this element)
125-
and values that are [=ordered sets=] of [=strings=]
126-
(part names that are selectable inside this element).
121+
Each element has a <dfn export for="element">forwarded part name list</dfn>
122+
which is a [=list=] of [=pairs=]
123+
containing a [=string=] for the inner part being forwarded
124+
and a [=string=] giving the name it will be exposed as.
127125

128126
Each <a>shadow root</a> can be thought of as having a <dfn export for="shadow root">part element map</dfn>
129127
with keys that are [=strings=]
130128
and values that are [=ordered sets=] of elements.
131129

132-
The part element map is described
130+
The [=part element map=] is described
133131
only as part of the algorithm for calculating style in this spec.
134132
It is not exposed via the DOM,
135133
as calculating it may be expensive
136134
and exposing it could allow access to elements inside closed shadow roots.
137135

138-
Part element maps are affected by the addition and removal of elements
139-
and changes to the part name lists and part name maps of elements in the DOM.
140-
141-
To calculate the part element map of a shadow root, |outerRoot|:
142-
143-
<ol>
144-
<li>For each element, |el| within |outerRoot|
145-
<ol>
146-
<li>For each |name| in |el|'s part name list,
147-
add |el| to |outerRoot|'s part element map
148-
under the key |name|.
149-
<li>If |el| is a shadow host itself
150-
then let |innerRoot| be its shadow root:
151-
<ol>
152-
<li>Calculate |innerRoot|'s part element map.
153-
<li>For each key, |outerName|, in |el|'s part name map
154-
and for each token |innerName| under that key
155-
look up |innerName| in |innerRoot|'s shadow part element map
156-
to get a (possibly empty) set of elements
157-
and add these elements to |outerRoot|'s part element map under |outerName|
158-
</ol>
159-
</ol>
160-
</ol>
136+
[=Part element maps=] are affected by the addition and removal of elements
137+
and changes to the [=part name lists=] and [=forwarded part name lists=] of elements in the DOM.
138+
139+
<div algorithm>
140+
To <dfn>calculate the [=part element map=]</dfn> of a shadow root, |outerRoot|:
141+
142+
1. For each [=descendant=] |el| within |outerRoot|:
143+
1. For each |name| in |el|'s [=part name list=],
144+
[=list/append=] |el| to |outerRoot|'s [=part element map=][|name|].
145+
2. If |el| is a [=shadow host=] itself
146+
then let |innerRoot| be its shadow root.
147+
3. [=calculate the part element map|Calculate=] |innerRoot|'s [=part element map=].
148+
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|]
152+
</div>
161153

162154

163155
Naming a Shadow Element: the <{html-global/part}> attribute {#part-attr}
@@ -201,10 +193,12 @@ Each part mapping is one of:
201193

202194
<dl class=switch>
203195
: <code>innerIdent : outerIdent</code>
204-
:: this adds «[ outerIdent → innerIdent ]» to el's <a>part name map</a>.
196+
:: Adds <code>innerIdent</code>/<code>outerIdent</code> to el's <a>forwarded part name list</a>.
205197

206198
: <code>ident</code>
207-
:: Is shorthand for <code>ident : ident</code>.
199+
:: Adds <code>ident</code>/<code>ident</code> to el's <a>forwarded part name list</a>.
200+
201+
Note: This is shorthand for <code>ident : ident</code>.
208202

209203
: anything else
210204
:: Ignored for error-recovery / future compatibility.

0 commit comments

Comments
 (0)