-
Notifications
You must be signed in to change notification settings - Fork 784
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
Conversation
lib/core/public/cleanup-plugins.js
Outdated
@@ -23,7 +23,7 @@ function cleanupPlugins(resolve, reject) { | |||
}); | |||
}); | |||
|
|||
axe.utils.toArray(document.querySelectorAll('frame, iframe')).forEach(function (frame) { | |||
axe.utils.getFrames().forEach(function (frame) { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
This enables |
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
lib/core/public/cleanup-plugins.js
Outdated
command: 'cleanup-plugin' | ||
}, res, rej); | ||
}); | ||
}); | ||
|
||
flattenedTree = undefined |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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, { |
There was a problem hiding this comment.
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)
…js (dequelabs#492) Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Supports [WWD-845] https://dequesrc.atlassian.net/browse/WWD-845