Skip to content

Commit

Permalink
fix: add check for secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
Brentlok committed Dec 16, 2024
1 parent 3c6b3c7 commit 42c4cc7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
10 changes: 2 additions & 8 deletions src/web/shadowRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { UnistylesTheme, UnistylesValues } from '../types'
import { UnistylesListener } from './listener'
import { UnistylesRegistry } from './registry'
import { deepMergeObjects } from '../utils'
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument, keyInObject } from './utils'
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument } from './utils'
import { getVariants } from './variants'

type Style = UnistylesValues | ((...args: Array<any>) => UnistylesValues)
Expand Down Expand Up @@ -67,13 +67,6 @@ class UnistylesShadowRegistryBuilder {

// Regular style
if (!secrets) {
Object.keys(unistyleStyle).forEach(key => {
if (keyInObject(ref.style, key)) {
// @ts-expect-error - Styles won't have read only properties
ref.style[key] = ''
}
})

return unistyleStyle as UnistylesValues
}

Expand Down Expand Up @@ -133,6 +126,7 @@ class UnistylesShadowRegistryBuilder {
this.classNamesMap.set(ref, newClassNames)
// Add new classnames to the ref
ref.classList.add(...newClassNames)
ref.removeAttribute('styles')

return newClassNames
}
Expand Down
2 changes: 1 addition & 1 deletion src/web/utils/unistyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
}

export const extractSecrets = (object: any) => {
return keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
return object && keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
}

export const removeInlineStyles = (values: UnistylesValues) => {
Expand Down

0 comments on commit 42c4cc7

Please sign in to comment.