Skip to content

Commit 80730b4

Browse files
author
Quang Phan
committed
refactor(toc): setAttribute -> toggleAttribute for toc markers
1 parent f7e8013 commit 80730b4

3 files changed

Lines changed: 7 additions & 2 deletions

File tree

.changeset/wicked-jokes-arrive.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@svelte-put/toc': patch
3+
---
4+
5+
refator to `toggleAttribute` in favor of `setAttribute` for markers

packages/actions/toc/src/lib/toc.action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ export const toc: Action<HTMLElement, TocParameters, TocEventAttributes> = funct
162162
}
163163

164164
// mark that this element has been processed by `toc`
165-
element.setAttribute(ATTRIBUTES.toc, '');
165+
element.toggleAttribute(ATTRIBUTES.toc, true);
166166
}
167167
cache[id] = { parameters: resolved, items };
168168
}

packages/actions/toc/src/lib/toc.internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ export function processAnchor(
127127
element.parentNode?.insertBefore(a, element.nextSibling);
128128
break;
129129
}
130-
a.setAttribute(ATTRIBUTES.anchor, '');
130+
a.toggleAttribute(ATTRIBUTES.anchor, true);
131131
} else {
132132
// already processed by `@svelte-put/preprocess-auto-slug`
133133
// search for the injected anchor element

0 commit comments

Comments
 (0)