Skip to content

Commit

Permalink
Fix missing highlighting on iteration change (exercism#6364)
Browse files Browse the repository at this point in the history
* Update yarn lock

* Unset `data-highlighted` before highlightingAllAlways
  • Loading branch information
dem4ron authored Oct 20, 2023
1 parent 3d6499e commit 52c3cf2
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
5 changes: 2 additions & 3 deletions app/javascript/hooks/use-syntax-highlighting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@ export function useContinuousHighlighting<T extends HTMLElement>(
const parentRef = useRef<T | null>(null)

useLayoutEffect(() => {
if (!parentRef.current) {
return
}
if (!parentRef.current) return

highlightAllAlways(parentRef.current as unknown as ParentNode)
}, [html])

Expand Down
1 change: 1 addition & 0 deletions app/javascript/utils/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ export const highlightAll = (parent: ParentNode = document): void => {

export const highlightAllAlways = (parent: ParentNode = document): void => {
parent.querySelectorAll<HTMLElement>('pre code').forEach((block) => {
block.removeAttribute('data-highlighted')
highlightBlock(block)
})
}
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5202,7 +5202,7 @@ highlight.js@11.2.0:
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.2.0.tgz#a7e3b8c1fdc4f0538b93b2dc2ddd53a40c6ab0f0"
integrity sha512-JOySjtOEcyG8s4MLR2MNbLUyaXqUunmSnL2kdV/KuGJOmHZuAR5xC54Ko7goAXBWNhf09Vy3B+U7vR62UZ/0iw==

highlight.js@^11.5.1:
highlight.js@11.9.0:
version "11.9.0"
resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-11.9.0.tgz#04ab9ee43b52a41a047432c8103e2158a1b8b5b0"
integrity sha512-fJ7cW7fQGCYAkgv4CPfwFHrfd/cLS4Hau96JuJ+ZTOWhjnhoeN1ub1tFmALm/+lW5z4WCAuAV9bm05AP0mS6Gw==
Expand Down

0 comments on commit 52c3cf2

Please sign in to comment.