Skip to content

Commit 0f6e89f

Browse files
committed
Add ‘role=doc-endnote’ to list items
1 parent 8b8a199 commit 0f6e89f

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ module.exports = (config, options = {}) => {
6666
const listItemAttrs = attrs({
6767
id: `${footnote.id}-note`,
6868
class: cl('list-item'),
69+
role: 'doc-endnote',
6970
})
7071
const backLinkAttrs = attrs({
7172
class: cl('back-link'),

test.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ describe('The `footnoteref` paired shortcode', () => {
3737
describe('The `footnotes` shortcode', () => {
3838
const { footnoteref, footnotes } = plugin(config, {
3939
titleId: 'footnotes-title-id',
40-
title: 'Footnote references'
40+
title: 'Footnote references',
4141
})
4242
const context = { page: { inputPath: 'tests/footnotes' } }
4343
const root = document.createElement('div')
@@ -84,6 +84,7 @@ describe('The `footnotes` shortcode', () => {
8484
expect(listItem).not.toBeUndefined()
8585
expect(listItem.getAttribute('class')).toBe('Footnotes__list-item')
8686
expect(listItem.getAttribute('id')).toBe('foo-id-note')
87+
expect(listItem.getAttribute('role')).toBe('doc-endnote')
8788
expect(listItem.textContent).toBe('foo-footnote ↩')
8889
})
8990

@@ -132,16 +133,21 @@ describe('The `eleventy-plugin-footnotes` plugin', () => {
132133
expect(root.querySelector('footer').getAttribute('class')).toBe('Kitty')
133134
expect(root.querySelector('h2').getAttribute('class')).toBe('Kitty__title')
134135
expect(root.querySelector('ol').getAttribute('class')).toBe('Kitty__list')
135-
expect(root.querySelector('li').getAttribute('class')).toBe('Kitty__list-item')
136-
expect(root.querySelector('li a').getAttribute('class')).toBe('Kitty__back-link')
136+
expect(root.querySelector('li').getAttribute('class')).toBe(
137+
'Kitty__list-item'
138+
)
139+
expect(root.querySelector('li a').getAttribute('class')).toBe(
140+
'Kitty__back-link'
141+
)
137142
})
138143

139144
it('should allow customising the back link label', () => {
140-
const { footnotes } = plugin(config, { backLinkLabel: (_, i) => 'Go to ' + (i + 1) })
145+
const { footnotes } = plugin(config, {
146+
backLinkLabel: (_, i) => 'Go to ' + (i + 1),
147+
})
141148
const root = document.createElement('div')
142149
root.innerHTML = footnotes.call(context)
143150

144151
expect(root.querySelector('a').getAttribute('aria-label')).toBe('Go to 1')
145-
146152
})
147153
})

0 commit comments

Comments
 (0)