diff --git a/lighthouse-core/audits/seo/anchor-href.js b/lighthouse-core/audits/seo/anchor-href.js index f8958f160b14..804e23b102d0 100644 --- a/lighthouse-core/audits/seo/anchor-href.js +++ b/lighthouse-core/audits/seo/anchor-href.js @@ -70,7 +70,7 @@ class AnchorHref extends Audit { return { node: { type: 'node', - snippet: node.outerHTML + node.text, + snippet: node.outerHTML, }, }; }); diff --git a/lighthouse-core/test/results/artifacts/artifacts.json b/lighthouse-core/test/results/artifacts/artifacts.json index 13d0134538de..fa6f50c02161 100644 --- a/lighthouse-core/test/results/artifacts/artifacts.json +++ b/lighthouse-core/test/results/artifacts/artifacts.json @@ -1749,49 +1749,124 @@ "AnchorElements": [ { "href": "https://www.google.com/", - "outerHTML": "Hello", + "rawHref": "https://www.google.com/", + "text": "external link", "rel": "", "target": "_blank", - "text": "external link" + "devtoolsNodePath": "3,HTML,1,BODY,36,A", + "selector": "body > a", + "nodeLabel": "external link", + "outerHTML": "" }, { "href": "", - "outerHTML": "Hello", + "rawHref": "", + "text": "external link", "rel": "", "target": "_blank", - "text": "Hello" + "devtoolsNodePath": "3,HTML,1,BODY,38,A", + "selector": "body > a", + "nodeLabel": "external link", + "outerHTML": "" }, { "href": "https://www.google.com/", - "outerHTML": "Hello", + "rawHref": "https://www.google.com/", + "text": "external link", + "rel": "nofollow", + "target": "_blank", + "devtoolsNodePath": "3,HTML,1,BODY,40,A", + "selector": "body > a", + "nodeLabel": "external link", + "outerHTML": "" + }, + { + "href": "https://www.google.com/", + "rawHref": "https://www.google.com/", + "text": "external link that uses rel noopener and another unrelated rel attribute", + "rel": "noopener nofollow", + "target": "_blank", + "devtoolsNodePath": "3,HTML,1,BODY,42,A", + "selector": "body > a", + "nodeLabel": "external link that uses rel noopener and another unrelated rel attribute", + "outerHTML": "" + }, + { + "href": "https://www.google.com/", + "rawHref": "https://www.google.com/", + "text": "external link that uses rel noreferrer and another unrelated rel attribute", + "rel": "noreferrer nofollow", + "target": "_blank", + "devtoolsNodePath": "3,HTML,1,BODY,44,A", + "selector": "body > a", + "nodeLabel": "external link that uses rel noreferrer and another unrelated rel attribute", + "outerHTML": "" + }, + { + "href": "https://www.google.com/", + "rawHref": "https://www.google.com/", + "text": "external link that uses rel noopener", "rel": "noopener", "target": "_blank", - "text": "external link that uses noopener" + "devtoolsNodePath": "3,HTML,1,BODY,46,A", + "selector": "body > a", + "nodeLabel": "external link that uses rel noopener", + "outerHTML": "" }, { "href": "https://www.google.com/", - "outerHTML": "Hello", - "rel": "nofollow", + "rawHref": "https://www.google.com/", + "text": "external link that uses rel noreferrer", + "rel": "noreferrer", + "target": "_blank", + "devtoolsNodePath": "3,HTML,1,BODY,48,A", + "selector": "body > a", + "nodeLabel": "external link that uses rel noreferrer", + "outerHTML": "" + }, + { + "href": "https://www.google.com/", + "rawHref": "https://www.google.com/", + "text": "external link that uses rel noopener and noreferrer", + "rel": "noopener noreferrer", "target": "_blank", - "text": "external link that uses nofollow" + "devtoolsNodePath": "3,HTML,1,BODY,50,A", + "selector": "body > a", + "nodeLabel": "external link that uses rel noopener and noreferrer", + "outerHTML": "" }, { - "href": "http://localhost:10200/dobetterweb/doesnotexist", + "href": "http://localhost:54106/dobetterweb/doesnotexist", + "rawHref": "./doesnotexist", + "text": "internal link is ok", "rel": "", "target": "_blank", - "text": "internal link is ok" + "devtoolsNodePath": "3,HTML,1,BODY,52,A", + "selector": "body > a", + "nodeLabel": "internal link is ok", + "outerHTML": "" }, { "href": "javascript:void(0)", + "rawHref": "javascript:void(0)", + "text": "", "rel": "", "target": "_blank", - "text": "" + "devtoolsNodePath": "3,HTML,1,BODY,54,A", + "selector": "body > a", + "nodeLabel": "a", + "outerHTML": "" }, { "href": "mailto:inbox@email.com", + "rawHref": "mailto:inbox@email.com", + "text": "", "rel": "", "target": "_blank", - "text": "" + "devtoolsNodePath": "3,HTML,1,BODY,56,A", + "selector": "body > a", + "nodeLabel": "a", + "outerHTML": "" } ], "AppCacheManifest": "clock.appcache", @@ -2105,4 +2180,4 @@ }, "MainDocumentContent": "\n\n\n\n\n\nDoBetterWeb Mega Tester... Of Death\n\n\n\n\n\n\n\n\n\n\n\n \n \n \n \n \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n\n\n\n
\n

Do better web tester page

\n Hi there!\n\n \n \n Facebook\n \n \n \n
\n\n
touchmove section
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", "SourceMaps": [] -} \ No newline at end of file +} diff --git a/lighthouse-core/test/results/sample_v2.json b/lighthouse-core/test/results/sample_v2.json index bf79ae786992..fe4d0fcdf01c 100644 --- a/lighthouse-core/test/results/sample_v2.json +++ b/lighthouse-core/test/results/sample_v2.json @@ -2988,7 +2988,7 @@ "score": 0, "scoreDisplayMode": "binary", "warnings": [ - "Unable to determine the destination for anchor (
Hello). If not used as a hyperlink, consider removing target=_blank." + "Unable to determine the destination for anchor (). If not used as a hyperlink, consider removing target=_blank." ], "details": { "type": "table", @@ -3003,41 +3003,54 @@ { "node": { "type": "node", - "path": "", - "selector": "", - "nodeLabel": "", - "snippet": "Hello" + "path": "3,HTML,1,BODY,36,A", + "selector": "body > a", + "nodeLabel": "external link", + "snippet": "" }, "href": "https://www.google.com/", "target": "_blank", "rel": "", - "outerHTML": "Hello" + "outerHTML": "" }, { "node": { "type": "node", - "path": "", - "selector": "", - "nodeLabel": "", - "snippet": "Hello" + "path": "3,HTML,1,BODY,38,A", + "selector": "body > a", + "nodeLabel": "external link", + "snippet": "" }, "href": "Unknown", "target": "_blank", "rel": "", - "outerHTML": "Hello" + "outerHTML": "" }, { "node": { "type": "node", - "path": "", - "selector": "", - "nodeLabel": "", - "snippet": "Hello" + "path": "3,HTML,1,BODY,40,A", + "selector": "body > a", + "nodeLabel": "external link", + "snippet": "" }, "href": "https://www.google.com/", "target": "_blank", "rel": "nofollow", - "outerHTML": "Hello" + "outerHTML": "" + }, + { + "node": { + "type": "node", + "path": "3,HTML,1,BODY,52,A", + "selector": "body > a", + "nodeLabel": "internal link is ok", + "snippet": "" + }, + "href": "http://localhost:54106/dobetterweb/doesnotexist", + "target": "_blank", + "rel": "", + "outerHTML": "" } ] } @@ -3468,43 +3481,13 @@ { "node": { "type": "node", - "snippet": "Helloexternal link" - } - }, - { - "node": { - "type": "node", - "snippet": "HelloHello" - } - }, - { - "node": { - "type": "node", - "snippet": "Helloexternal link that uses noopener" - } - }, - { - "node": { - "type": "node", - "snippet": "Helloexternal link that uses nofollow" - } - }, - { - "node": { - "type": "node", - "snippet": "undefinedinternal link is ok" - } - }, - { - "node": { - "type": "node", - "snippet": "undefined" + "snippet": "" } }, { "node": { "type": "node", - "snippet": "undefined" + "snippet": "" } } ] @@ -6722,7 +6705,7 @@ "lighthouse-core/audits/dobetterweb/external-anchors-use-rel-noopener.js | warning": [ { "values": { - "anchorHTML": "Hello" + "anchorHTML": "" }, "path": "audits[external-anchors-use-rel-noopener].warnings[0]" }