Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use mark instead of span #75

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openstax/highlighter",
"version": "1.13.0",
"version": "1.14.0",
"main": "dist/index.js",
"license": "MIT",
"files": [
Expand Down
76 changes: 38 additions & 38 deletions src/__snapshots__/injectHighlightWrappers.spec.ts.snap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`inject highlight wrappers for figure with caption for highlight ending on an <img> in chrome and safari 1`] = `
<span
<mark
class="highlight first text yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -13,11 +13,11 @@ exports[`inject highlight wrappers for figure with caption for highlight ending
tabindex="0"
/>
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.
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight ending on an <img> in chrome and safari 2`] = `
<span
<mark
class="highlight block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -33,11 +33,11 @@ exports[`inject highlight wrappers for figure with caption for highlight ending
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight ending on an <img> in firefox 1`] = `
<span
<mark
class="highlight first text yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -49,11 +49,11 @@ exports[`inject highlight wrappers for figure with caption for highlight ending
tabindex="0"
/>
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.
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight ending on an <img> in firefox 2`] = `
<span
<mark
class="highlight block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -69,11 +69,11 @@ exports[`inject highlight wrappers for figure with caption for highlight ending
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting and ending on an <img> in chrome and safari 1`] = `
<span
<mark
class="highlight first block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -95,11 +95,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting and ending on an <img> in firefox 1`] = `
<span
<mark
class="highlight first block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -121,11 +121,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> in chrome and safari 1`] = `
<span
<mark
class="highlight first block yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -142,11 +142,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
id="test-img"
src="/apps/archive/20210713.205645/resources/b1b5ba97150addc831c534413ca324a72c4e374b"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> in chrome and safari 2`] = `
<span
<mark
class="highlight text last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -157,11 +157,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> in firefox 1`] = `
<span
<mark
class="highlight first block yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -178,11 +178,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
id="test-img"
src="/apps/archive/20210713.205645/resources/b1b5ba97150addc831c534413ca324a72c4e374b"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> in firefox 2`] = `
<span
<mark
class="highlight text last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -193,11 +193,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> where img is first element on page in chrome 1`] = `
<span
<mark
class="highlight first block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -219,11 +219,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> where img is first element on page in firefox 1`] = `
<span
<mark
class="highlight first block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -245,11 +245,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for figure with caption for highlight starting on an <img> where img is first element on page in safari 1`] = `
<span
<mark
class="highlight first block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -271,11 +271,11 @@ exports[`inject highlight wrappers for figure with caption for highlight startin
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for img between paragraphs in chrome and safari 1`] = `
<span
<mark
class="highlight first text yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -287,11 +287,11 @@ exports[`inject highlight wrappers for img between paragraphs in chrome and safa
tabindex="0"
/>
the first terms, the outer terms, the inner terms, and then the last terms of each binomial.
</span>
</mark>
`;

exports[`inject highlight wrappers for img between paragraphs in chrome and safari 2`] = `
<span
<mark
class="highlight block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -307,11 +307,11 @@ exports[`inject highlight wrappers for img between paragraphs in chrome and safa
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for img between paragraphs in firefox 1`] = `
<span
<mark
class="highlight first text yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -323,11 +323,11 @@ exports[`inject highlight wrappers for img between paragraphs in firefox 1`] = `
tabindex="0"
/>
the first terms, the outer terms, the inner terms, and then the last terms of each binomial.
</span>
</mark>
`;

exports[`inject highlight wrappers for img between paragraphs in firefox 2`] = `
<span
<mark
class="highlight block last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -343,11 +343,11 @@ exports[`inject highlight wrappers for img between paragraphs in firefox 2`] = `
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for text followed by section in chrome and safari 1`] = `
<span
<mark
class="highlight first text last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -364,11 +364,11 @@ exports[`inject highlight wrappers for text followed by section in chrome and sa
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;

exports[`inject highlight wrappers for text followed by section in firefox 1`] = `
<span
<mark
class="highlight first text last yellow"
data-highlight-id="some-highlight"
data-highlighted="true"
Expand All @@ -385,5 +385,5 @@ exports[`inject highlight wrappers for text followed by section in firefox 1`] =
data-for-screenreaders="true"
data-highlight-id="some-highlight"
/>
</span>
</mark>
`;
10 changes: 5 additions & 5 deletions src/injectHighlightWrappers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ function mergeSiblingHighlights(highlights: Node[]) {
* Creates wrapper for highlights.
*/
function createWrapper(options: any) {
const span = document.createElement('span');
span.className = options.className;
const el = document.createElement('mark');
el.className = options.className;
if (options.timestamp) {
span.setAttribute(TIMESTAMP_ATTR, options.timestamp);
el.setAttribute(TIMESTAMP_ATTR, options.timestamp);
}
if (options.id) {
span.setAttribute(DATA_ID_ATTR, options.id);
el.setAttribute(DATA_ID_ATTR, options.id);
}
return span;
return el;
}

function isHighlight(el: any): el is HTMLElement {
Expand Down
Loading