Skip to content

Commit

Permalink
use parentNode.removeChild() for compatibility with IE
Browse files Browse the repository at this point in the history
  • Loading branch information
marvinjude committed Aug 9, 2022
1 parent 76b2302 commit c971686
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const removePrevHeadElements = () => {
const prevHeadNodes = document.querySelectorAll(`[data-gatsby-head]`)

for (const node of prevHeadNodes) {
node.remove()
node.parentNode.removeChild(node)
}
}

Expand Down Expand Up @@ -52,7 +52,9 @@ const onHeadRendered = () => {
seenIds.set(id, validHeadNodes.length - 1)
} else {
const indexOfPreviouslyInsertedNode = seenIds.get(id)
validHeadNodes[indexOfPreviouslyInsertedNode].remove()
validHeadNodes[indexOfPreviouslyInsertedNode].parentNode.removeChild(
validHeadNodes[indexOfPreviouslyInsertedNode]
)
validHeadNodes[indexOfPreviouslyInsertedNode] = clonedNode
}
} else {
Expand All @@ -72,7 +74,7 @@ const onHeadRendered = () => {
diffNodes({
oldNodes: existingHeadElements,
newNodes: validHeadNodes,
onStale: node => node.remove(),
onStale: node => node.parentNode.removeChild(node),
onNew: node => newHeadNodes.push(node),
})

Expand Down

0 comments on commit c971686

Please sign in to comment.