Skip to content

Commit

Permalink
fix(theme): Restore former globalThis.Prism (#10618)
Browse files Browse the repository at this point in the history
  • Loading branch information
slorber authored Oct 25, 2024
1 parent d723a1e commit 52e50d2
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export default function prismIncludeLanguages(
// avoid polluting global namespace.
// You can mutate PrismObject: registering plugins, deleting languages... As
// long as you don't re-assign it

const PrismBefore = globalThis.Prism;
globalThis.Prism = PrismObject;

additionalLanguages.forEach((lang) => {
Expand All @@ -34,5 +36,9 @@ export default function prismIncludeLanguages(
require(`prismjs/components/prism-${lang}`);
});

// Clean up and eventually restore former globalThis.Prism object (if any)
delete (globalThis as Optional<typeof globalThis, 'Prism'>).Prism;
if (typeof PrismBefore !== 'undefined') {
globalThis.Prism = PrismObject;
}
}

0 comments on commit 52e50d2

Please sign in to comment.