Skip to content

Commit

Permalink
fix: remove localStorage watch (blink)
Browse files Browse the repository at this point in the history
  • Loading branch information
Atinux committed Oct 7, 2022
1 parent f5253fe commit b7b32ed
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 14 deletions.
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -26,7 +26,6 @@
- Force a page to a specific color mode (perfect for incremental development)
- Works with client-side and universal rendering
- Auto detect system [color-mode](https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-mode)
- Sync dark mode across tabs and windows 馃攧
- Supports IE9+ 馃懘

[馃摉  Read more](https://color-mode.nuxtjs.org)
Expand Down
1 change: 0 additions & 1 deletion docs/content/1.index.md
Expand Up @@ -19,7 +19,6 @@ v3 of `@nuxtjs/color-mode` is compatible with [Nuxt 3 and Nuxt Bridge](https://v
- Force a page to a specific color mode (perfect for incremental development)
- Works with client-side and universal rendering
- Auto detect system [color-mode](https://drafts.csswg.org/mediaqueries-5/#descdef-media-prefers-color-mode)
- Sync dark mode across tabs and windows 馃攧
- Supports IE9+ 馃懘

## Live demo
Expand Down
1 change: 1 addition & 0 deletions playground/app.vue
Expand Up @@ -8,6 +8,7 @@
<p class="note">
Demo based on <a href="https://color-mode.nuxtjs.org">@nuxtjs/color-mode</a> module.
</p>
<iframe src="http://localhost:3000" />
</div>
</template>

Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt.config.js
@@ -1,5 +1,5 @@
import { defineNuxtConfig } from 'nuxt'
import colorModeModule from '..'
import colorModeModule from '../src/module'

export default defineNuxtConfig({
components: { global: true, dirs: ['~/components'] },
Expand Down
11 changes: 0 additions & 11 deletions src/runtime/plugin.client.ts
Expand Up @@ -71,14 +71,6 @@ export default defineNuxtPlugin((nuxtApp) => {
})
}

function watchStorageChange () {
window.addEventListener('storage', (e) => {
if (e.key === storageKey && e.newValue && colorMode.preference !== e.newValue) {
colorMode.preference = e.newValue
}
})
}

watch(() => colorMode.preference, (preference) => {
if (colorMode.forced) {
return
Expand All @@ -104,9 +96,6 @@ export default defineNuxtPlugin((nuxtApp) => {
}

nuxtApp.hook('app:mounted', () => {
if (window.localStorage) {
watchStorageChange()
}
if (colorMode.unknown) {
colorMode.preference = helper.preference
colorMode.value = helper.value
Expand Down

1 comment on commit b7b32ed

@P4sca1
Copy link

@P4sca1 P4sca1 commented on b7b32ed Oct 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why has this feature been removed? @Atinux

Please sign in to comment.