diff --git a/packages/gatsby/cache-dir/head/head-export-handler-for-browser.js b/packages/gatsby/cache-dir/head/head-export-handler-for-browser.js index f5efc17fbcf34..f7f5234f1fe2f 100644 --- a/packages/gatsby/cache-dir/head/head-export-handler-for-browser.js +++ b/packages/gatsby/cache-dir/head/head-export-handler-for-browser.js @@ -16,7 +16,10 @@ const hiddenRoot = document.createElement(`div`) const removePrevHeadElements = () => { const prevHeadNodes = document.querySelectorAll(`[data-gatsby-head]`) - prevHeadNodes.forEach(e => e.remove()) + + for (const node of prevHeadNodes) { + node.remove() + } } const onHeadRendered = () => {