mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-05-20 15:09:40 +00:00
Add parent checking before inserting or removing the child
This commit is contained in:
@@ -111,7 +111,9 @@ export default function CustomContextMenu(props) {
|
||||
document.body.appendChild(tempInput);
|
||||
tempInput.select();
|
||||
document.execCommand('copy');
|
||||
document.body.removeChild(tempInput);
|
||||
if (tempInput && tempInput.parentNode && tempInput.parentNode.contains(tempInput)) {
|
||||
tempInput.parentNode.removeChild(tempInput);
|
||||
}
|
||||
// alert("Text copied: " + selectedText);
|
||||
} else {
|
||||
// alert("Please select some text first.");
|
||||
|
||||
@@ -24,7 +24,9 @@ export default function DifyChatbot() {
|
||||
return () => {
|
||||
// 在组件卸载时清理 script 标签
|
||||
const existingScript = document.getElementById(siteConfig('DIFY_CHATBOT_TOKEN')); // 注意调用 siteConfig()
|
||||
if (existingScript) document.body.removeChild(existingScript);
|
||||
if (existingScript && existingScript.parentNode && existingScript.parentNode.contains(existingScript)) {
|
||||
existingScript.parentNode.removeChild(existingScript);
|
||||
}
|
||||
};
|
||||
}, []); // 注意依赖数组为空,意味着脚本将仅在加载页面时执行一次
|
||||
|
||||
|
||||
@@ -116,7 +116,11 @@ class MessengerCustomerChat extends Component {
|
||||
js = d.createElement(s);
|
||||
js.id = id;
|
||||
js.src = `https://connect.facebook.net/${language}/sdk/xfbml.customerchat.js`;
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
if (fjs && fjs.parentNode && fjs.parentNode.contains(fjs)) {
|
||||
fjs.parentNode.insertBefore(js, fjs);
|
||||
} else {
|
||||
document.body.appendChild(js);
|
||||
}
|
||||
})(document, 'script', 'facebook-jssdk');
|
||||
/* eslint-enable */
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ export function PWA(post, siteInfo) {
|
||||
|
||||
// 删除已有的 manifest link 元素(如果存在)
|
||||
const existingManifest = document.querySelector('link[rel="manifest"]')
|
||||
if (existingManifest) {
|
||||
if (existingManifest && existingManifest.parentNode && existingManifest.parentNode.contains(existingManifest)) {
|
||||
existingManifest.parentNode.removeChild(existingManifest)
|
||||
}
|
||||
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user