File tree 2 files changed +17
-8
lines changed
packages/svelte-ux/src/lib/components
2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " svelte-ux " : patch
3
+ ---
4
+
5
+ Create ` FALLBACK_SETTINGS ` on demand so we don't call ` createThemeStore() ` eagerly and thus set ` <html class="dark"> ` unintentional
Original file line number Diff line number Diff line change @@ -118,19 +118,23 @@ export function settings(settings: SettingsInput): Settings {
118
118
} ) ;
119
119
}
120
120
121
- const FALLBACK_CONTEXT : Settings = {
122
- currentTheme : createThemeStore ( { light : [ 'light' ] , dark : [ 'dark' ] } ) ,
123
- componentSettingsCache : { } ,
124
- ...createLocaleStores ( { } ) ,
125
- } ;
121
+ let FALLBACK_SETTINGS : Settings | null = null ;
122
+
123
+ function getFallbackSettings ( ) {
124
+ FALLBACK_SETTINGS = FALLBACK_SETTINGS ?? {
125
+ currentTheme : createThemeStore ( { light : [ 'light' ] , dark : [ 'dark' ] } ) ,
126
+ componentSettingsCache : { } ,
127
+ ...createLocaleStores ( { } ) ,
128
+ } ;
129
+ return FALLBACK_SETTINGS ;
130
+ }
126
131
127
132
export function getSettings ( ) : Settings {
128
133
// in a try/catch to be able to test w/o svelte components
129
-
130
134
try {
131
- return getContext < Settings > ( settingsKey ) ?? FALLBACK_CONTEXT ;
135
+ return getContext < Settings > ( settingsKey ) ?? getFallbackSettings ( ) ;
132
136
} catch ( error ) {
133
- return FALLBACK_CONTEXT ;
137
+ return getFallbackSettings ( ) ;
134
138
}
135
139
}
136
140
You can’t perform that action at this time.
0 commit comments