Skip to content

Commit

Permalink
fix: clipboard aria-label & term role (#490)
Browse files Browse the repository at this point in the history
* fix: clipboard aria-label & term role

* update snapshot
  • Loading branch information
martyanovandrey authored Aug 21, 2024
1 parent b4f3c2c commit abc298f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/transform/plugins/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const wrapInClipboard = (element: string | undefined, id: number) => {
return `
<div class="yfm-clipboard">
${element}
<button class="yfm-clipboard-button">
<button class="yfm-clipboard-button" aria-label="Copy">
<svg width="16" height="16" viewBox="0 0 24 24" class="yfm-clipboard-icon" data-animation="${id}">
<path
fill="currentColor"
Expand Down
1 change: 1 addition & 0 deletions src/transform/plugins/term/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ const term: MarkdownItPluginCb = (md, options) => {
token = new state.Token('term_open', 'i', 1);
token.attrSet('class', 'yfm yfm-term_title');
token.attrSet('term-key', ':' + termKey);
token.attrSet('role', 'term');
token.attrSet('aria-describedby', ':' + termKey + '_element');
token.attrSet('tabindex', '0');
token.attrSet('id', generateID());
Expand Down
6 changes: 3 additions & 3 deletions test/__snapshots__/term.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ exports[`Terms Should create term in table with definition template 1`] = `
</thead>
<tbody>
<tr>
<td><i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i></td>
<td><i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" role=\\"term\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i></td>
<td style=\\"text-align:center\\">1993</td>
</tr>
</tbody>
Expand All @@ -44,13 +44,13 @@ exports[`Terms Should create term in table with definition template 1`] = `
exports[`Terms Should create term in text with definition template 1`] = `
"<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>
</dfn></template><h1>Web</h1>
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" role=\\"term\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
"
`;
exports[`Terms Term should use content from include 1`] = `
"<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>
</dfn></template><h1>Web</h1>
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
<p>The <i class=\\"yfm yfm-term_title\\" term-key=\\":html\\" role=\\"term\\" aria-describedby=\\":html_element\\" tabindex=\\"0\\" id=\\"\\">HTML</i> specification</p>
"
`;

0 comments on commit abc298f

Please sign in to comment.