Skip to content

Commit abc298f

Browse files
fix: clipboard aria-label & term role (#490)
* fix: clipboard aria-label & term role * update snapshot
1 parent b4f3c2c commit abc298f

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/transform/plugins/code.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const wrapInClipboard = (element: string | undefined, id: number) => {
77
return `
88
<div class="yfm-clipboard">
99
${element}
10-
<button class="yfm-clipboard-button">
10+
<button class="yfm-clipboard-button" aria-label="Copy">
1111
<svg width="16" height="16" viewBox="0 0 24 24" class="yfm-clipboard-icon" data-animation="${id}">
1212
<path
1313
fill="currentColor"

src/transform/plugins/term/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ const term: MarkdownItPluginCb = (md, options) => {
9999
token = new state.Token('term_open', 'i', 1);
100100
token.attrSet('class', 'yfm yfm-term_title');
101101
token.attrSet('term-key', ':' + termKey);
102+
token.attrSet('role', 'term');
102103
token.attrSet('aria-describedby', ':' + termKey + '_element');
103104
token.attrSet('tabindex', '0');
104105
token.attrSet('id', generateID());

test/__snapshots__/term.test.ts.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ exports[`Terms Should create term in table with definition template 1`] = `
3333
</thead>
3434
<tbody>
3535
<tr>
36-
<td><i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i></td>
36+
<td><i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" role=\\"term\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i></td>
3737
<td style=\\"text-align:center\\">1993</td>
3838
</tr>
3939
</tbody>
@@ -44,13 +44,13 @@ exports[`Terms Should create term in table with definition template 1`] = `
4444
exports[`Terms Should create term in text with definition template 1`] = `
4545
"<template id=\\":html_template\\" label=\\"html\\"><dfn class=\\"yfm yfm-term_dfn\\" id=\\":html_element\\" role=\\"tooltip\\"><p>The HyperText Markup Language or <strong>HTML</strong> is the standard markup language for documents designed to be displayed in a web browser.</p>
4646
</dfn></template><h1>Web</h1>
47-
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
47+
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" role=\\"term\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
4848
"
4949
`;
5050
5151
exports[`Terms Term should use content from include 1`] = `
5252
"<template id=\\":html_template\\" label=\\"html\\"><dfn class=\\"yfm yfm-term_dfn\\" id=\\":html_element\\" role=\\"tooltip\\"><p>The HyperText Markup Language or <strong>HTML</strong> is the standard markup language for documents designed to be displayed in a web browser.</p>
5353
</dfn></template><h1>Web</h1>
54-
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
54+
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" role=\\"term\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
5555
"
5656
`;

0 commit comments

Comments
 (0)