@@ -5,6 +5,7 @@ import type { PropType } from 'vue'
55import type { IconifyIcon } from '@iconify/types'
66import type { NuxtIconRuntimeOptions , NuxtIconRuntimeServerOptions } from '../../types'
77import type { IconifyIconCustomizeCallback } from './shared'
8+ import { hash } from 'ohash'
89import { loadIcon , resolveCustomizeFn } from './shared'
910import { useAppConfig , useNuxtApp , useHead , useRuntimeConfig , onServerPrefetch } from '#imports'
1011
@@ -81,7 +82,16 @@ export const NuxtIconCss = /* @__PURE__ */ defineComponent({
8182 setup ( props ) {
8283 const nuxt = useNuxtApp ( )
8384 const options = useAppConfig ( ) . icon as NuxtIconRuntimeOptions
84- const cssClass = computed ( ( ) => props . name ? options . cssSelectorPrefix + props . name : '' )
85+ const cssClass = computed ( ( ) => {
86+ if ( ! props . name ) return ''
87+ const base = options . cssSelectorPrefix + props . name
88+ // When a per-instance customize function is provided, append a hash of its source
89+ // so that distinct customizations get their own selector and CSS rule.
90+ if ( typeof props . customize === 'function' ) {
91+ return base + '--customized-' + hash ( props . customize . toString ( ) )
92+ }
93+ return base
94+ } )
8595
8696 function getIcon ( name : string ) {
8797 if ( ! name )
@@ -191,10 +201,10 @@ export const NuxtIconCss = /* @__PURE__ */ defineComponent({
191201 } )
192202 } )
193203 }
194- // Dedupe CSS
195- if ( props . name && ! ssrCSS . has ( props . name ) ) {
204+ // Dedupe CSS (use cssClass as key to support per-instance customization)
205+ if ( cssClass . value && ! ssrCSS . has ( cssClass . value ) ) {
196206 const css = getCSS ( icon , false )
197- ssrCSS . set ( props . name , css )
207+ ssrCSS . set ( cssClass . value , css )
198208 }
199209 return null
200210 }
0 commit comments