From 54d95280740ff1286b3a60bf3a95141c29fea8ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Sat, 6 Mar 2021 20:43:01 +0100 Subject: [PATCH] fix: recursive clone triggered when "locales" object made reactive Ensure that we always clone the original "locales" when assigning to "$i18n.locales" so that if the object is made reactive by the user, we don't attempt to clone that. Resolves #1075 --- src/templates/plugin.main.js | 2 +- test/browser.test.js | 2 +- test/fixture/basic/pages/index.vue | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/templates/plugin.main.js b/src/templates/plugin.main.js index 9bfe2dad8..e4f6198fa 100644 --- a/src/templates/plugin.main.js +++ b/src/templates/plugin.main.js @@ -275,7 +275,7 @@ export default async (context) => { } const extendVueI18nInstance = i18n => { - i18n.locales = locales + i18n.locales = klona(locales) i18n.localeProperties = klona(locales.find(l => l[LOCALE_CODE_KEY] === i18n.locale) || { code: i18n.locale }) i18n.defaultLocale = defaultLocale i18n.differentDomains = differentDomains diff --git a/test/browser.test.js b/test/browser.test.js index 77715ec48..3b2cf9499 100644 --- a/test/browser.test.js +++ b/test/browser.test.js @@ -18,7 +18,7 @@ async function createBrowser () { async function navigate (page, path) { await page.evaluate(path => { return new Promise((resolve, reject) => { - window.$nuxt.$router.push(path, () => resolve(), reject) + window.$nuxt.$router.push(path, () => resolve(null), reject) }) }, path) await new Promise(resolve => setTimeout(resolve, 50)) diff --git a/test/fixture/basic/pages/index.vue b/test/fixture/basic/pages/index.vue index 6cb90dc65..22c9e95c7 100644 --- a/test/fixture/basic/pages/index.vue +++ b/test/fixture/basic/pages/index.vue @@ -8,6 +8,7 @@