Skip to content

Commit 52e50d2

Browse files
authored
fix(theme): Restore former globalThis.Prism (#10618)
1 parent d723a1e commit 52e50d2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/docusaurus-theme-classic/src/theme/prism-include-languages.ts

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export default function prismIncludeLanguages(
2323
// avoid polluting global namespace.
2424
// You can mutate PrismObject: registering plugins, deleting languages... As
2525
// long as you don't re-assign it
26+
27+
const PrismBefore = globalThis.Prism;
2628
globalThis.Prism = PrismObject;
2729

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

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

0 commit comments

Comments
 (0)