@@ -58,26 +58,16 @@ export const Core = ({ t, nonce, dp }: CoreProps) => {
5858
5959 useEffect ( ( ) => {
6060 const restoreTransitions = modifyTransition ( t , nonce ) ;
61- const serverTargetEl = document . querySelector ( "[data-ndm]" ) ;
62- // We need to always update documentElement to support Tailwind configuration
63- // skipcq: JS-D008, JS-0042 -> map keyword is shorter
64- [ document . documentElement , serverTargetEl ] . map ( el => {
65- if ( el ) {
66- const clsList = el . classList ;
67- modes . forEach ( mode => clsList . remove ( mode ) ) ;
68- clsList . add ( resolvedMode ) ;
69- [
70- [ "sm" , systemMode ] ,
71- [ "rm" , resolvedMode ] ,
72- [ "m" , mode ] ,
73- ] . forEach ( ( [ dataLabel , value ] ) => el . setAttribute ( `data-${ dataLabel } ` , value ) ) ;
74- }
75- } ) ;
61+ const el = document . documentElement ;
62+ el . classList [ resolvedMode === DARK ? "add" : "remove" ] ( resolvedMode ) ;
63+ [
64+ [ "sm" , systemMode ] ,
65+ [ "rm" , resolvedMode ] ,
66+ [ "m" , mode ] ,
67+ ] . forEach ( ( [ dataLabel , value ] ) => el . setAttribute ( `data-${ dataLabel } ` , value ) ) ;
7668 restoreTransitions ( ) ;
7769 // System mode is decided by current system state and need not be stored in localStorage
78- ! dp && localStorage . setItem ( COOKIE_KEY , mode ) ;
79- if ( ! dp && serverTargetEl )
80- document . cookie = `${ COOKIE_KEY } =${ resolvedMode } ;max-age=31536000;SameSite=Strict;` ;
70+ localStorage . setItem ( COOKIE_KEY , mode ) ;
8171 } , [ resolvedMode , systemMode , mode , t , nonce ] ) ;
8272
8373 return null ;
0 commit comments