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

core(noopener): use node detail type #10242

Merged
merged 8 commits into from
Jan 23, 2020
Merged

core(noopener): use node detail type #10242

merged 8 commits into from
Jan 23, 2020

Conversation

Beytoven
Copy link
Contributor

Summary

We want a better UX for viewing the noopener audit's results in devtools.

This does change the audit's result shape which is a breaking change.

image

Related Issues/PRs

Fixes #5110

href: anchor.href || 'Unknown',
target: anchor.target || '',
rel: anchor.rel || '',
outerHTML: anchor.outerHTML || '',
};
return item;
Copy link
Collaborator

Choose a reason for hiding this comment

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

failingAnchors -> items


if (node instanceof HTMLAnchorElement) {
return {
href: node.href,
// TODO(blasingame): Deprecate text in favor of nodeLabel
Copy link
Collaborator

Choose a reason for hiding this comment

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

6.0 is coming up, we should do this now.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not totally convinced we want to remove this. The purpose of including some of these properties was so that plugins could take advantage of generic information that is of common interest and untruncated text seems like something useful to surface. The alt text feature of getNodeLabel is pretty nice though.

I'd say we can resolve at a later date, but @connorjclark is right that 6.0 is imminent.

Options I see, but feel free to add:

  1. Add nodeLabel and keep text
  2. Remove text and keep nodeLabel
  3. Change text to just be output of getNodeLabel
  4. Make truncateLength a parameter to getNodeLabel and use it as text without truncation

I'm a fan of 1 and 4, personally. Thoughts anyone?

Copy link
Member

Choose a reason for hiding this comment

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

yah option 1 works for me. thanks for thinking it through

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've removed the TODO as option 1 is already taken care of as part of this PR.

Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

nice work @Beytoven! heads up it's gonna need a yarn update:sample-json to fix the CI tests :)

/** Label for a column in a data table; entries will be the values of the html "rel" attribute from link in a page. */
columnRel: 'Rel',
/** Label for a column in a data table; entries will be the HTML elements that failed the audit. Anchors are DOM elements that are links. */
failingAnchorsHeader: 'Failing Anchors',
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: when text is exclusively used for a column label we tend to follow the columnNameOfThing pattern


if (node instanceof HTMLAnchorElement) {
return {
href: node.href,
// TODO(blasingame): Deprecate text in favor of nodeLabel
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not totally convinced we want to remove this. The purpose of including some of these properties was so that plugins could take advantage of generic information that is of common interest and untruncated text seems like something useful to surface. The alt text feature of getNodeLabel is pretty nice though.

I'd say we can resolve at a later date, but @connorjclark is right that 6.0 is imminent.

Options I see, but feel free to add:

  1. Add nodeLabel and keep text
  2. Remove text and keep nodeLabel
  3. Change text to just be output of getNodeLabel
  4. Make truncateLength a parameter to getNodeLabel and use it as text without truncation

I'm a fan of 1 and 4, personally. Thoughts anyone?

@@ -88,19 +84,16 @@ describe('External anchors use rel="noopener"', () => {
});
assert.equal(auditResult.score, 0);
assert.equal(auditResult.details.items.length, 2);
assert.equal(auditResult.details.items.length, 2);
assert.equal(auditResult.details.items[0].node.type, 'node');
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we could get at least 1 assertion on the structure of the node value?

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 added the devtoolsNodePath to the AnchorElement mocks and added a couple assertions on the resulting item's node path. Not sure if this is what you meant though.

@@ -289,6 +289,9 @@ declare global {
href: string
text: string
target: string
path: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

in scripts gatherer (one of the other "public" gatherers) we named this devtoolsNodePath to make it clear this isn't for general use like the selector.

Rename failingAnchorsHeader to columnFailingAnchors to be in line with
established pattern.
Add assertions on the value of devtoolNodePath to unit tests.
@vercel vercel bot temporarily deployed to Preview January 22, 2020 21:14 Inactive
Copy link
Collaborator

@patrickhulce patrickhulce left a comment

Choose a reason for hiding this comment

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

LGTM! 🎉

@connorjclark connorjclark changed the title core(noopener): use itemType node for noopener audit core(noopener): use node detail type Jan 23, 2020
Copy link
Collaborator

@connorjclark connorjclark left a comment

Choose a reason for hiding this comment

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

LGTM 🎉

@connorjclark connorjclark merged commit 1e9f2f9 into master Jan 23, 2020
@connorjclark connorjclark deleted the noopener branch January 23, 2020 22:19
@connorjclark
Copy link
Collaborator

connorjclark commented Jan 23, 2020

BTW, I noticed you're adding some really descriptive messages for the commits here. Just so ya know, we squash all PRs and generally don't include a commit body (just the title of the PR), unless it's a rather complex change that warrants more. As long as the PR title is a well crafted commit message, that's enough.

Of course, you should still be descriptive in each commit if you like. It's probably helpful for reviewers. But not 100% necessary imo.

@paulirish
Copy link
Member

BTW, I noticed you're adding some really descriptive messages for the commits here.

Yup, mostly what connor said. 👍 good call

the PR title is key and it's populated from the first commit message.. personally i try to craft that one right, but you can obv make the PR title whatever before you send it out.

as for all subsequent commits, yeah... often we're very lazy and use 'feedback' or 'json' or 'tests', etc. you can feel free to stay descriptive if its helpful for you. but it's true that it wont be seen in the master branch's history. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

move rel-noopener audit to report nodes
5 participants