-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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 DomNode renderer #2206
Add DomNode renderer #2206
Conversation
5ee6497
to
1067183
Compare
const path = []; | ||
while (node && node.parentNode) { | ||
const index = getNodeIndex(node); | ||
path.push([index, node.nodeName]); |
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.
is this pavel's special node selector methodology? what would be the downside to augmenting a regular CSS selector with nth-child
?
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.
yeah in the protocol docs it says "proprietary format". :)
impl's: backend side,frontend side
downsides of using selectors:
- can't reference text nodes, document fragments, or the doctype node
- can't pierce shadow dom
* @param {!DetailsRenderer.NodeDetailsJSON} item | ||
* @return {!Element} | ||
*/ | ||
_renderNode(item) { |
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.
node is slightly ambiguous at this level, can we make it DOMNode or something? when I just looked at the title of the PR I thought it was a renderer running in "node.js" 😆
* @param {string} text | ||
* @return {!Node} | ||
*/ | ||
createText(text) { |
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 doesn't seem used?
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.
true.
lighthouse-cli/bin.ts
Outdated
@@ -66,6 +67,8 @@ if (cliFlags.configPath) { | |||
config = require(cliFlags.configPath); | |||
} else if (cliFlags.perf) { | |||
config = perfOnlyConfig; | |||
} else if (cliFlags.a11y) { |
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.
only downside here is that people might think you could do lighthouse --perf --a11y
and get both, what if we supported that by nixing the config files and just appending each category that's enabled to onlyCategories
of a default extending config
I can pickup that separately though
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.
heh true. ill probably kick this out of the PR. :)
lighthouse-cli/cli-flags.ts
Outdated
@@ -82,6 +82,7 @@ export function getFlags() { | |||
'chrome-flags': | |||
'Custom flags to pass to Chrome (space-delimited). For a full list of flags, see http://peter.sh/experiments/chromium-command-line-switches/.', | |||
'perf': 'Use a performance-test-only configuration', | |||
'a11y': 'Use an accessibility-test-only configuration', |
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.
if you keep the flag, please update the readme.
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.
ill probably nuke, but thx!
}); | ||
|
||
// Adapated from DevTools' SDK.DOMNode.prototype.path |
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.
Adapted
|
||
// Adapated from DevTools' SDK.DOMNode.prototype.path | ||
// https://github.com/ChromeDevTools/devtools-frontend/blob/7a2e162ddefd/front_end/sdk/DOMModel.js#L530-L552 | ||
// TODO: Doesn't handle frames or shadow roots... |
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.
Can you file a bug on this? We have some other "handle shadow root" updates to make in the codebase. We can address them all after io.
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 think there's also work ongoing in axe to support shadow dom. @alice may know more.
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 don't have any updates here, sorry. I know Marcy was thinking of taking a look at it but she might have gotten swamped with other things.
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.
filed #2243
// https://github.com/ChromeDevTools/devtools-frontend/blob/7a2e162ddefd/front_end/sdk/DOMModel.js#L530-L552 | ||
// TODO: Doesn't handle frames or shadow roots... | ||
function getNodePath(node) { | ||
/* global Node */ |
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.
prefer this at the top.
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 move to the top top.
look like global
and env
are file-wide so we couldnt have it be scoped to a function anyway. bummer.
while (node = node.previousSibling) { | ||
// skip empty text nodes | ||
if (node.nodeType === Node.TEXT_NODE && | ||
node.textContent.trim().length === 0) continue; |
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.
2 space indent
return path.join(','); | ||
} | ||
|
||
function getOuterHTMLSnippet(node) { |
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.
docs
1067183
to
cc050f5
Compare
I'm getting a ": Object reference chain is too long" error on some pages: It's due to an object being > 1000 objects deep. I imagine it's something that happens to the Axe result object on big pages (e.g. https://developers.google.com/web/tools/chrome-devtools/ ) but it's not clear. cc @robdodson |
cc050f5
to
5da3ee6
Compare
Hm I'm not able to reproduce this error. Do you have some specific steps I could follow? I tried running axe extension, axe cli, and audits against the link you provided and they all work fine for me. |
I'd say try it with this patch? it's possible the new |
@paulirish I was also not able to reproduce this. I tried using an extension and I tried by simply going to the page, using the console to execute the axe-core 2.2.0 Javascript and then running |
8883bbd
to
b81b881
Compare
b81b881
to
4b00b65
Compare
I'm pretty sure I managed to squash all these. thank you guys for testing this and trying to give it a shot. |
@dylanb i don't think it'll be a problem for us anymore, but ultimately the challenge was that we wanted |
This reverts commit 6a8b604.
@patrickhulce this is ready for another look right? |
yep tests passing and ready for review |
@paulirish It was in fact a bug, it has been fixed. Upgrade to 2.2.1 to get the fix dequelabs/axe-core#334 |
Adding a new node/element renderer for the report. Primarily assisting all the a11y audits right now.
I've also added a--a11y
CLI flag because 1) it was super easy and 2) it was really handy. But I can revert, no big deal.This also enables node revealing/hovering in devtools. The WIP DevTools-side patch:
https://codereview.chromium.org/2849463002/diff/1/third_party/WebKit/Source/devtools/front_end/audits2/Audits2Panel.js
It looks like this in the standalone report:
![image](https://cloud.githubusercontent.com/assets/39191/25884957/9e9b2b18-350a-11e7-9040-279d16743fd5.png)