Add parent checking before inserting or removing the child

This commit is contained in:
Phillweston
2024-05-15 12:46:17 +00:00
parent 8c5d31498b
commit a66c416fa4
12 changed files with 34 additions and 15 deletions

View File

@@ -74,7 +74,7 @@ const loadPrismThemeCSS = (isDarkMode, prismThemeSwitch, prismThemeDarkPath, pri
PRISM_PREVIOUS = prismThemeDarkPath
}
const previousTheme = document.querySelector(`link[href="${PRISM_PREVIOUS}"]`)
if (previousTheme) {
if (previousTheme && previousTheme.parentNode && previousTheme.parentNode.contains(previousTheme)) {
previousTheme.parentNode.removeChild(previousTheme)
}
loadExternalResource(PRISM_THEME, 'css')