Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add assignedElements() method to <slot> #2269

Merged
merged 7 commits into from Dec 19, 2017
Merged

Add assignedElements() method to <slot> #2269

merged 7 commits into from Dec 19, 2017

Conversation

cyrilletuzi
Copy link
Contributor

@cyrilletuzi cyrilletuzi commented Jan 16, 2017

Fixes WICG/webcomponents#602

Add assignedElements() method to <slot>, similar to assignedNodes(), but returning Element nodes only.


/acknowledgements.html ( diff )
/scripting.html ( diff )

@annevk annevk added the needs tests Moving the issue forward requires someone to write tests label Jan 16, 2017
@annevk
Copy link
Member

annevk commented Jan 16, 2017

Thank you. I think from the issue it's clear that there's interest from implementers. What we also need is tests. It would be best to add those to https://github.com/w3c/web-platform-tests/tree/master/shadow-dom I think.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, mostly nits.

source Outdated
@@ -58667,6 +58668,9 @@ dictionary <dfn>AssignedNodesOptions</dfn> {
<dd>Returns <var>slot</var>'s <span>assigned nodes</span>, if any, and <var>slot</var>'s children
otherwise, and does the same for any <code>slot</code> elements encountered therein, recursively,
until there are no <code>slot</code> elements left.</dd>

<dt><var>slot</var> . <code subdfn data-x="dom-slot-assignedElements">assignedElements</code>()</dt>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs one more space of indentation.

source Outdated
@@ -58667,6 +58668,9 @@ dictionary <dfn>AssignedNodesOptions</dfn> {
<dd>Returns <var>slot</var>'s <span>assigned nodes</span>, if any, and <var>slot</var>'s children
otherwise, and does the same for any <code>slot</code> elements encountered therein, recursively,
until there are no <code>slot</code> elements left.</dd>

<dt><var>slot</var> . <code subdfn data-x="dom-slot-assignedElements">assignedElements</code>()</dt>
<dd>Returns <var>slot</var>'s <span>Element</span> <span>assigned nodes</span> only.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe "Return slot's assigned nodes, limited to elements"? No need to reference the Element class here I think.

Also, you should describe what happens when the parameter is passed as well.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(The reason to not use Element here is because this is non-normative and meant to be a more friendly description of what's going on.)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I first added a description with the parameter too, but as I thought the "Note" section is non normative and just here to help, I chose to keep it light, as it's quite obvious it will do the same as assignedNodes() but just for elements. But tell me if it's better to add this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though it's obvious, it's better to be consistent, since we'll definitely get folks asking why it's missing if it is.

source Outdated

<ol>
<li><p>If the value of <var>options</var>'s <code data-x="">flatten</code> member is false, then
return this element's <span>assigned nodes</span>, filtered to return only <span>Element</span> nodes.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<code>Element</code> here and below. Also, we have a line length limit of 100 columns. Also seems to apply below.

@cyrilletuzi
Copy link
Contributor Author

Done.

Should I write the tests too ? If so, should I group them with assignedNodes() tests as it's quite the same method, or should I do specific test groups ?

@annevk
Copy link
Member

annevk commented Jan 16, 2017

If you could write them that'd be great. Modifying the existing test resource for assignedNodes() seems good, but please make sure you use a distinct test() wrapper so they get their own reported failures.

@cyrilletuzi
Copy link
Contributor Author

Tests done in web-platform-tests/wpt#4541

annevk
annevk previously requested changes Jan 16, 2017
source Outdated
<dd>Returns <var>slot</var>'s <span>assigned nodes</span> limited to elements, if any, and
<var>slot</var>'s children limited to elements otherwise, and does the same for any
<code>slot</code> elements encountered therein, recursively, until there are no
<code>slot</code> elements left.</dd>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead we should say here that it returns the same as slot.assignedNodes({flatten:true}), limited to elements? The current sentence does not make much sense and this might be easier to write.

@annevk
Copy link
Member

annevk commented Jan 16, 2017

Tests look great, if you could ping this thread once they are reviewed and landed that would help.

@annevk annevk added addition/proposal New features or enhancements do not merge yet Pull request must not be merged per rationale in comment topic: shadow Relates to shadow trees (as defined in DOM) and removed needs tests Moving the issue forward requires someone to write tests labels Jan 16, 2017
@TimvdLippe
Copy link
Contributor

Tests have been accepted in web-platform-tests/wpt#8636 🎉

@annevk
Copy link
Member

annevk commented Dec 12, 2017

Great, unfortunately this PR has conflicts. Would you also be willing to work on a new specification PR @TimvdLippe? If not, I can probably take care of the conflicts sometime this week or next.

@hayatoito for next time, it'd be great to not merge the web-platform-tests PR until we can also update the standard around the same time. Otherwise we might end up confusing people. (I don't think it's a particularly big deal now, since it's a minor addition, but worth keeping in mind.)

@TimvdLippe
Copy link
Contributor

@annevk As I am not familiar with this repository nor the original author of this PR, I think you resolving conflicts is the fastest solution 😄 Thanks in advance!

@hayatoito
Copy link
Member

hayatoito commented Dec 14, 2017

@annevk I got it. Let me keep it in mind. I thought that the lack of a test was a blocking issue for merging this PR . Let me confirm that a PR is really ready to be merged before merging a test from the next time.

Thank you for taking care of it!

@annevk annevk dismissed their stale review December 16, 2017 17:33

Addressed my own nits

@annevk
Copy link
Member

annevk commented Dec 16, 2017

Commit:

Add <slot>.assignedElements()

Equivalent to assignedNodes(), limited to returning element nodes.

Tests: https://github.com/w3c/web-platform-tests/pull/8636.

Fixes https://github.com/w3c/webcomponents/issues/602.

@domenic final review?

@annevk annevk removed the do not merge yet Pull request must not be merged per rationale in comment label Dec 17, 2017
@TimvdLippe
Copy link
Contributor

@annevk Awesome, thanks for your help!

Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nits

source Outdated
<dd>Returns <var>slot</var>'s <span>assigned nodes</span>, limited to elements.</dd>

<dt><var>slot</var> . <code data-x="dom-slot-assignedElements">assignedElements</code>({ flatten: true })</dt>
<dd>Returns the same as <code data-x="dom-slot-assignedNodes">assignedElements({ flatten: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/assignedElements/assignedNodes

source Outdated

<ol>
<li><p>If the value of <var>options</var>'s <code data-x="">flatten</code> member is false, then
return this element's <span>assigned nodes</span>, filtered to return only <code>Element</code>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/return only/contain only

source Outdated
nodes.</p></li>

<li><p>Return the result of <span>finding flattened slotables</span> with this element, filtered
to return only <code>Element</code> nodes.</p></li>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/return only/contain only

@annevk annevk merged commit b626a63 into whatwg:master Dec 19, 2017
@cyrilletuzi cyrilletuzi deleted the assigned-elements branch December 19, 2017 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addition/proposal New features or enhancements topic: shadow Relates to shadow trees (as defined in DOM)
Development

Successfully merging this pull request may close these issues.

None yet

5 participants