Skip to content

Commit

Permalink
Merge pull request #523 from jpudysz/fix/nested-array-styles
Browse files Browse the repository at this point in the history
fix: nested array styles on the web
  • Loading branch information
jpudysz authored Jan 27, 2025
2 parents 2a62cba + 7519922 commit 2760e8b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/core/getClassname.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import type { UnistylesValues } from '../types';
import { UnistylesShadowRegistry } from '../web';
import type { UnistylesValues } from '../types'
import { UnistylesWeb } from '../web'

export const getClassName = (unistyle: UnistylesValues | undefined | Array<UnistylesValues>) => {
if (!unistyle) {
return undefined
}

// @ts-expect-error hidden from TS
const { hash, injectedClassName } = UnistylesShadowRegistry.addStyles(Array.isArray(unistyle) ? unistyle : [unistyle])
const { hash, injectedClassName } = UnistylesWeb.shadowRegistry.addStyles(
Array.isArray(unistyle) ? unistyle.flat(Number.POSITIVE_INFINITY) : [unistyle]
)

return hash ? { $$css: true, hash, injectedClassName } : undefined
}

0 comments on commit 2760e8b

Please sign in to comment.