From 9c65b7d101b9b7ccd172772ef9d9ee9bb891449f Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sat, 23 May 2020 22:30:09 +0200 Subject: [PATCH 1/2] fix($core): check if meta is from head before removing it --- .../@vuepress/core/lib/client/root-mixins/updateMeta.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js b/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js index eb9aebbf22..9329871239 100644 --- a/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js +++ b/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js @@ -61,9 +61,10 @@ export default { */ function updateMetaTags (newMetaTags, currentMetaTags) { if (currentMetaTags) { - [...currentMetaTags].forEach(c => { - document.head.removeChild(c) - }) + [...currentMetaTags].filter(c => c.parentNode === document.head) + .forEach(c => { + document.head.removeChild(c) + }) } if (newMetaTags) { return newMetaTags.map(m => { From a9ca8fe1e2f46047c6600b79daadbc11491f3953 Mon Sep 17 00:00:00 2001 From: Hugo Alliaume Date: Sat, 13 Jun 2020 21:09:42 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: ULIVZ <472590061@qq.com> --- .../@vuepress/core/lib/client/root-mixins/updateMeta.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js b/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js index 9329871239..485f544d38 100644 --- a/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js +++ b/packages/@vuepress/core/lib/client/root-mixins/updateMeta.js @@ -61,10 +61,9 @@ export default { */ function updateMetaTags (newMetaTags, currentMetaTags) { if (currentMetaTags) { - [...currentMetaTags].filter(c => c.parentNode === document.head) - .forEach(c => { - document.head.removeChild(c) - }) + [...currentMetaTags] + .filter(c => c.parentNode === document.head) + .forEach(c => document.head.removeChild(c)) } if (newMetaTags) { return newMetaTags.map(m => {