File tree 1 file changed +10
-6
lines changed
1 file changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -156,10 +156,14 @@ export const NuxtIconCss = /* @__PURE__ */ defineComponent({
156
156
)
157
157
}
158
158
159
- if ( import . meta. server ) {
160
- const configs = ( useRuntimeConfig ( ) . icon || { } ) as NuxtIconRuntimeServerOptions
161
- if ( ! configs ?. serverKnownCssClasses ?. includes ( cssClass . value ) ) {
162
- onServerPrefetch ( async ( ) => {
159
+ // We need to always call this hook to make use Vue correctly detect this component as async
160
+ // This makes sure `useId` is consistent across server and client
161
+ // @see https://github.com/nuxt/icon/issues/310
162
+ onServerPrefetch ( async ( ) => {
163
+ // For dead code elimination
164
+ if ( import . meta. server ) {
165
+ const configs = ( useRuntimeConfig ( ) . icon || { } ) as NuxtIconRuntimeServerOptions
166
+ if ( ! configs ?. serverKnownCssClasses ?. includes ( cssClass . value ) ) {
163
167
const icon = await loadIcon ( props . name , options . fetchTimeout ) . catch ( ( ) => null )
164
168
if ( ! icon )
165
169
return null
@@ -190,9 +194,9 @@ export const NuxtIconCss = /* @__PURE__ */ defineComponent({
190
194
ssrCSS . set ( props . name , css )
191
195
}
192
196
return null
193
- } )
197
+ }
194
198
}
195
- }
199
+ } )
196
200
197
201
return ( ) => h ( 'span' , { class : [ 'iconify' , cssClass . value ] } )
198
202
} ,
You can’t perform that action at this time.
0 commit comments