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

fix: Let findUp work on shadow root children #447

Merged
merged 4 commits into from
Jul 18, 2017
Merged

Conversation

WilcoFiers
Copy link
Contributor

Should help resolve #422.

@@ -9,33 +9,24 @@
* @return {HTMLElement|null} Either the matching HTMLElement or `null` if there was no match
*/
dom.findUp = function (element, target) {
'use strict';
Copy link
Contributor

Choose a reason for hiding this comment

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

These changes don't seem to actually change anything in terms of functionality - is this purely a performance fix?

Copy link
Contributor

Choose a reason for hiding this comment

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

ok, so the difference here is that if the starting node is the highest node in the shadow DOM, then the old code did not find a matching host node - whereas this code does?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The problem is that if the child is a directly on the shadow root, it would start looking from the host (outside the shadow), even though the matches array still only contained elements inside the shadow tree.

Followup thought, should this use element.matches() instead of doing querySelectAll() and see if the element is included? I imagine that'd be faster.

});

(shadowSupport.v1 ? it : xit)('should work on shadow root children', function () {
fixture.innerHTML = '<div role="list"><div id="something"></div></div>';
Copy link
Contributor

Choose a reason for hiding this comment

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

shouldn't this attach to the div with role="list"?

@WilcoFiers WilcoFiers mentioned this pull request Jul 18, 2017
@WilcoFiers WilcoFiers merged commit 0f98481 into shadowDOM Jul 18, 2017
@dylanb dylanb deleted the sd/find-up-bug branch July 18, 2017 18:47
mrtnvh pushed a commit to mrtnvh/axe-core that referenced this pull request Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants