lighthouse 9.5.0-dev.20220615 → 9.5.0-dev.20220616
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/report/renderer/dom.js
CHANGED
|
@@ -133,9 +133,13 @@ export class DOM {
|
|
|
133
133
|
const element = this.createElement('span');
|
|
134
134
|
|
|
135
135
|
for (const segment of Util.splitMarkdownLink(text)) {
|
|
136
|
+
const processedSegment = segment.text.includes('`') ?
|
|
137
|
+
this.convertMarkdownCodeSnippets(segment.text) :
|
|
138
|
+
segment.text;
|
|
139
|
+
|
|
136
140
|
if (!segment.isLink) {
|
|
137
141
|
// Plain text segment.
|
|
138
|
-
element.append(
|
|
142
|
+
element.append(processedSegment);
|
|
139
143
|
continue;
|
|
140
144
|
}
|
|
141
145
|
|
|
@@ -151,7 +155,7 @@ export class DOM {
|
|
|
151
155
|
const a = this.createElement('a');
|
|
152
156
|
a.rel = 'noopener';
|
|
153
157
|
a.target = '_blank';
|
|
154
|
-
a.
|
|
158
|
+
a.append(processedSegment);
|
|
155
159
|
this.safelySetHref(a, url.href);
|
|
156
160
|
element.append(a);
|
|
157
161
|
}
|
|
@@ -96,6 +96,21 @@ describe('DOM', () => {
|
|
|
96
96
|
'and some text afterwards.', 'link with spaces in brackets');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
it('correctly converts code snippets', () => {
|
|
100
|
+
let result = dom.convertMarkdownLinkSnippets(
|
|
101
|
+
'Some `code`. [Learn more](http://example.com).');
|
|
102
|
+
assert.equal(result.innerHTML,
|
|
103
|
+
'<span>Some <code>code</code>. </span>' +
|
|
104
|
+
'<a rel="noopener" target="_blank" href="http://example.com/">Learn more</a>.');
|
|
105
|
+
|
|
106
|
+
result = dom.convertMarkdownLinkSnippets(
|
|
107
|
+
'[link with `code`](https://example.com/foo) and some text afterwards.');
|
|
108
|
+
assert.equal(result.innerHTML,
|
|
109
|
+
'<a rel="noopener" target="_blank" href="https://example.com/foo">' +
|
|
110
|
+
'<span>link with <code>code</code></span>' +
|
|
111
|
+
'</a> and some text afterwards.', 'link with code snippet inside');
|
|
112
|
+
});
|
|
113
|
+
|
|
99
114
|
it('handles invalid urls', () => {
|
|
100
115
|
const text = 'Text has [bad](https:///) link.';
|
|
101
116
|
assert.throws(() => {
|
|
@@ -120,8 +135,9 @@ describe('DOM', () => {
|
|
|
120
135
|
const text = 'Ensuring `<td>` cells using the `[headers]` are good. ' +
|
|
121
136
|
'[Learn more](https://dequeuniversity.com/rules/axe/3.1/td-headers-attr).';
|
|
122
137
|
const result = dom.convertMarkdownLinkSnippets(text);
|
|
123
|
-
assert.equal(result.innerHTML,
|
|
124
|
-
'
|
|
138
|
+
assert.equal(result.innerHTML,
|
|
139
|
+
'<span>Ensuring <code><td></code> cells using the <code>[headers]</code> are ' +
|
|
140
|
+
'good. </span><a rel="noopener" target="_blank" href="https://dequeuniversity.com/rules/axe/3.1/td-headers-attr">Learn more</a>.');
|
|
125
141
|
});
|
|
126
142
|
|
|
127
143
|
it('appends utm params to the URLs with https://developers.google.com origin', () => {
|