@@ -115,7 +115,7 @@ function readFromCss(theme: Theme, path: string[]) {
115115 }
116116
117117 // We have to turn the map into object-like structure for v3 compatibility
118- let obj = { }
118+ let obj : Record < string , unknown > = { }
119119 let useNestedObjects = false // paths.some((path) => nestedKeys.has(path))
120120
121121 for ( let [ key , value ] of map ) {
@@ -134,20 +134,19 @@ function readFromCss(theme: Theme, path: string[]) {
134134 set ( obj , path , value )
135135 }
136136
137- if ( ' DEFAULT' in obj ) {
138- // The request looked like `theme(' animation.DEFAULT')` and was turned into
139- // a lookup for `--animation-*` and we should extract the value for the
140- // `DEFAULT` key from the list of possible values
141- if ( path [ path . length - 1 ] === 'DEFAULT' ) {
142- return obj . DEFAULT
143- }
137+ // If the request looked like `theme('animation. DEFAULT')` it would have been
138+ // turned into a lookup for `-- animation-*` so we should extract the value for
139+ // the `DEFAULT` key from the list of possible values. If there is no
140+ // `DEFAULT` in the list, there is no match so return `null`.
141+ if ( path [ path . length - 1 ] === 'DEFAULT' ) {
142+ return obj ? .DEFAULT ?? null
143+ }
144144
145- // The request looked like `theme('animation.spin')` and was turned into a
146- // lookup for `--animation-spin-*` which had only one entry which means it
147- // should be returned directly
148- if ( Object . keys ( obj ) . length === 1 ) {
149- return obj . DEFAULT
150- }
145+ // The request looked like `theme('animation.spin')` and was turned into a
146+ // lookup for `--animation-spin-*` which had only one entry which means it
147+ // should be returned directly.
148+ if ( 'DEFAULT' in obj && Object . keys ( obj ) . length === 1 ) {
149+ return obj . DEFAULT
151150 }
152151
153152 return obj
0 commit comments