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: use frame query that supports shadow dom #492

Merged
merged 1 commit into from
Aug 22, 2017
Merged

fix: use frame query that supports shadow dom #492

merged 1 commit into from
Aug 22, 2017

Conversation

isner
Copy link
Contributor

@isner isner commented Aug 18, 2017

@@ -23,7 +23,7 @@ function cleanupPlugins(resolve, reject) {
});
});

axe.utils.toArray(document.querySelectorAll('frame, iframe')).forEach(function (frame) {
axe.utils.getFrames().forEach(function (frame) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be able to use axe.utils.querySelectorAll(axe._tree, 'frame, iframe') instead.

Copy link
Contributor Author

@isner isner Aug 18, 2017

Choose a reason for hiding this comment

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

Thanks. I'll give that a try.

@isner isner changed the title feat: add frame query that supports shadow dom fix: use frame query that supports shadow dom Aug 18, 2017
@isner
Copy link
Contributor Author

isner commented Aug 18, 2017

This enables axe.cleanup to target frames embedded in shadow roots. This is necessary to support clearing highlights in such frames.

@@ -23,14 +23,18 @@ function cleanupPlugins(resolve, reject) {
});
});

axe.utils.toArray(document.querySelectorAll('frame, iframe')).forEach(function (frame) {
var flattenedTree = axe.utils.getFlattenedTree(document.body)
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 had to create a new flattened tree to support this functionality. The only other place in which a flattened tree is created is during the audit itself. Since axe.cleanup can be called at any arbitrary time, we can't reuse the same tree.

Copy link
Contributor

Choose a reason for hiding this comment

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

Turns out there was a lint error in this line (missing ;). Very strange this didn't get picked up in circle.

Copy link
Contributor

@WilcoFiers WilcoFiers left a comment

Choose a reason for hiding this comment

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

Looks good. Take out the one line I commented on and we can merge.

command: 'cleanup-plugin'
}, res, rej);
});
});

flattenedTree = undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't need this. Garbage collector will do this for you.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will do. I'm curious, though, why we need to manually free up the memory here: https://github.com/dequelabs/axe-core/blob/develop/lib/core/base/audit.js#L182

Copy link
Contributor

Choose a reason for hiding this comment

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

Because it's a global object. Here it's just a local variable. Once nothing can reference it anymore, it's picked up by the garbage collector.

q.defer(function (res, rej) {
return axe.utils.sendCommandToFrame(frame, {
return axe.utils.sendCommandToFrame(node.actualNode, {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is super tweaky, but I wonder if it would be more intuitive to write virtualNode.actualNode or vNode.actualNode so it communicates what that top level object is. That would help in other places too (but changing it everywhere is obvs outside the scope of this PR)

@WilcoFiers WilcoFiers merged commit 94008ff into dequelabs:develop Aug 22, 2017
mrtnvh pushed a commit to mrtnvh/axe-core that referenced this pull request Nov 24, 2023
…js (dequelabs#492)

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

3 participants