From d4ee8186e5073e248baa8cea6438f8a50f6a9f19 Mon Sep 17 00:00:00 2001 From: Benjamin Canac Date: Tue, 10 May 2022 10:26:36 +0200 Subject: [PATCH] fix(plugin): prevent infinite loop on watch (#145) --- src/runtime/plugin.client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/runtime/plugin.client.ts b/src/runtime/plugin.client.ts index 5ca52ff9..be4544e1 100644 --- a/src/runtime/plugin.client.ts +++ b/src/runtime/plugin.client.ts @@ -57,7 +57,7 @@ export default defineNuxtPlugin((nuxtApp) => { function watchStorageChange () { window.addEventListener('storage', (e) => { - if (e.key === storageKey) { + if (e.key === storageKey && e.newValue && colorMode.preference !== e.newValue) { colorMode.preference = e.newValue } })