diff --git a/src/Highlight.ts b/src/Highlight.ts index 2a742ae..416d034 100644 --- a/src/Highlight.ts +++ b/src/Highlight.ts @@ -91,21 +91,9 @@ export default class Highlight { return this; } - public updateStartMarker(el: Element, position: string) { - const marker = el.querySelector(`[${DATA_SCREEN_READERS_ATTR}][tabindex]`); - - if (!marker) { - return; - } - marker.textContent = this.getMessage(`i18n:highlighter:highlight:${position}`); - } - /** - * Add class 'focus' to all elements of this highlight. - */ public addFocusedStyles(): Highlight { this.elements.forEach((el: HTMLElement) => { el.setAttribute('aria-current', 'true'); - this.updateStartMarker(el, 'start-selected'); }); return this; } diff --git a/src/Highlighter.ts b/src/Highlighter.ts index a37ee3b..76d3ea2 100644 --- a/src/Highlighter.ts +++ b/src/Highlighter.ts @@ -114,7 +114,6 @@ export default class Highlighter { if (!highlight) { return; } - highlight.updateStartMarker(el, 'start'); }); } diff --git a/src/__snapshots__/injectHighlightWrappers.spec.ts.snap b/src/__snapshots__/injectHighlightWrappers.spec.ts.snap index 2b0e3b3..a419970 100644 --- a/src/__snapshots__/injectHighlightWrappers.spec.ts.snap +++ b/src/__snapshots__/injectHighlightWrappers.spec.ts.snap @@ -7,12 +7,11 @@ exports[`inject highlight wrappers for figure with caption for highlight ending data-highlighted="true" > - Start of highlight - + /> hardware store sells 16-ft ladders and 24-ft ladders. A window is located 12 feet above the ground. A ladder needs to be purchased that will reach the window from a point on the ground 5 feet from the building. `; @@ -30,11 +29,10 @@ exports[`inject highlight wrappers for figure with caption for highlight ending src="/apps/archive/20210713.205645/resources/b1b5ba97150addc831c534413ca324a72c4e374b" /> - End of highlight - + /> `; @@ -45,12 +43,11 @@ exports[`inject highlight wrappers for figure with caption for highlight ending data-highlighted="true" > - Start of highlight - + /> hardware store sells 16-ft ladders and 24-ft ladders. A window is located 12 feet above the ground. A ladder needs to be purchased that will reach the window from a point on the ground 5 feet from the building. `; @@ -68,11 +65,10 @@ exports[`inject highlight wrappers for figure with caption for highlight ending src="/apps/archive/20210713.205645/resources/b1b5ba97150addc831c534413ca324a72c4e374b" /> - End of highlight - + /> `; @@ -83,12 +79,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c - End of highlight - + /> `; @@ -111,12 +105,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c - End of highlight - + /> `; @@ -139,12 +131,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c Figure - End of highlight - + /> `; @@ -177,12 +167,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c Figure - End of highlight - + /> `; @@ -215,12 +203,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c - End of highlight - + /> `; @@ -243,12 +229,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c - End of highlight - + /> `; @@ -271,12 +255,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin data-highlighted="true" > - Start of highlight - + /> A right triangle with a base of 5 feet, a height of 12 feet, and a hypotenuse labeled c - End of highlight - + /> `; @@ -299,12 +281,11 @@ exports[`inject highlight wrappers for img between paragraphs in chrome and safa data-highlighted="true" > - Start of highlight - + /> the first terms, the outer terms, the inner terms, and then the last terms of each binomial. `; @@ -322,11 +303,10 @@ exports[`inject highlight wrappers for img between paragraphs in chrome and safa src="/apps/archive/20210713.205645/resources/eb942bf030580de7cb1d8c7d484771addceb7da6" /> - End of highlight - + /> `; @@ -337,12 +317,11 @@ exports[`inject highlight wrappers for img between paragraphs in firefox 1`] = ` data-highlighted="true" > - Start of highlight - + /> the first terms, the outer terms, the inner terms, and then the last terms of each binomial. `; @@ -360,11 +339,10 @@ exports[`inject highlight wrappers for img between paragraphs in firefox 2`] = ` src="/apps/archive/20210713.205645/resources/eb942bf030580de7cb1d8c7d484771addceb7da6" /> - End of highlight - + /> `; @@ -375,19 +353,17 @@ exports[`inject highlight wrappers for text followed by section in chrome and sa data-highlighted="true" > - Start of highlight - + /> How To - End of highlight - + /> `; @@ -398,18 +374,16 @@ exports[`inject highlight wrappers for text followed by section in firefox 1`] = data-highlighted="true" > - Start of highlight - + /> How To - End of highlight - + /> `; diff --git a/src/injectHighlightWrappers.spec.ts b/src/injectHighlightWrappers.spec.ts index 0468242..550432d 100644 --- a/src/injectHighlightWrappers.spec.ts +++ b/src/injectHighlightWrappers.spec.ts @@ -4,8 +4,7 @@ import { DATA_ATTR } from './injectHighlightWrappers'; import { adjacentTextSections, imageBetweenParagraphs, paragraphFigureAndCaption } from './injectHighlightWrappers.spec.data'; const messages: { [key: string]: string } = { - 'i18n:highlighter:highlight:end': 'End of highlight', - 'i18n:highlighter:highlight:start': 'Start of highlight', + 'i18n:highlighter:language': 'spanish', }; describe('inject highlight wrappers for figure with caption', () => { diff --git a/src/injectHighlightWrappers.ts b/src/injectHighlightWrappers.ts index 4b72fce..9a9c245 100644 --- a/src/injectHighlightWrappers.ts +++ b/src/injectHighlightWrappers.ts @@ -71,9 +71,12 @@ function createAndInsertNodeForScreenReaders(highlight: Highlight, element: HTML node.setAttribute(DATA_SCREEN_READERS_ATTR, 'true'); node.setAttribute(DATA_ID_ATTR, highlight.id); - const message = highlight.getMessage(`i18n:highlighter:highlight:${position}`); + const language = highlight.getMessage(`i18n:highlighter:language`); - node.textContent = message; + if (language) { + node.classList.add(language); + } + node.classList.add(position); if (position === 'start') { node.setAttribute('tabindex', '0');