mirror of
https://github.com/d0zingcat/NotionNext.git
synced 2026-06-03 23:16:52 +00:00
Add parent checking before inserting or removing the child
This commit is contained in:
@@ -258,7 +258,11 @@ const LayoutSlug = props => {
|
||||
videoWrapper.appendChild(figCaptionWrapper)
|
||||
}
|
||||
// 放入页面
|
||||
notionArticle.insertBefore(videoWrapper, notionArticle.firstChild)
|
||||
if (notionArticle.firstChild && notionArticle.contains(notionArticle.firstChild)) {
|
||||
notionArticle.insertBefore(videoWrapper, notionArticle.firstChild)
|
||||
} else {
|
||||
notionArticle.appendChild(videoWrapper)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,9 @@ const checkThemeDOM = () => {
|
||||
elements[elements.length - 1].scrollIntoView()
|
||||
// 删除前面的元素,只保留最后一个元素
|
||||
for (let i = 0; i < elements.length - 1; i++) {
|
||||
elements[i].parentNode.removeChild(elements[i])
|
||||
if (elements[i] && elements[i].parentNode && elements[i].parentNode.contains(elements[i])) {
|
||||
elements[i].parentNode.removeChild(elements[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user