@@ -2,13 +2,12 @@ import { computed, reactive, watch } from 'vue'
2
2
3
3
import type { ColorModeInstance } from './types'
4
4
import { defineNuxtPlugin , isVue2 , isVue3 , useRouter , useHead , useState } from '#imports'
5
- import { globalName , storageKey , dataValue } from '#color-mode-options'
5
+ import { globalName , storageKey , dataValue , disableTransition } from '#color-mode-options'
6
6
7
7
// Initialise to empty object to avoid hard error when hydrating app in test mode
8
8
const helper = ( window [ globalName ] || { } ) as unknown as {
9
9
preference : string
10
10
value : string
11
- disableTransition : boolean
12
11
getColorScheme : ( ) => string
13
12
addColorScheme : ( className : string ) => void
14
13
removeColorScheme : ( className : string ) => void
@@ -90,14 +89,14 @@ export default defineNuxtPlugin((nuxtApp) => {
90
89
91
90
watch ( ( ) => colorMode . value , ( newValue , oldValue ) => {
92
91
let style : HTMLStyleElement | undefined
93
- if ( helper . disableTransition ) {
92
+ if ( disableTransition ) {
94
93
style = window ! . document . createElement ( 'style' )
95
94
style . appendChild ( document . createTextNode ( '*{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}' ) )
96
95
window ! . document . head . appendChild ( style )
97
96
}
98
97
helper . removeColorScheme ( oldValue )
99
98
helper . addColorScheme ( newValue )
100
- if ( helper . disableTransition ) {
99
+ if ( disableTransition ) {
101
100
// Calling getComputedStyle forces the browser to redraw
102
101
// eslint-disable-next-line @typescript-eslint/no-unused-vars
103
102
const _ = window ! . getComputedStyle ( style ! ) . opacity
0 commit comments