Skip to content

Commit 42c4cc7

Browse files
committed
fix: add check for secrets
1 parent 3c6b3c7 commit 42c4cc7

File tree

2 files changed

+3
-9
lines changed

2 files changed

+3
-9
lines changed

src/web/shadowRegistry.ts

+2-8
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { UnistylesTheme, UnistylesValues } from '../types'
22
import { UnistylesListener } from './listener'
33
import { UnistylesRegistry } from './registry'
44
import { deepMergeObjects } from '../utils'
5-
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument, keyInObject } from './utils'
5+
import { equal, extractSecrets, extractUnistyleDependencies, isInDocument } from './utils'
66
import { getVariants } from './variants'
77

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

6868
// Regular style
6969
if (!secrets) {
70-
Object.keys(unistyleStyle).forEach(key => {
71-
if (keyInObject(ref.style, key)) {
72-
// @ts-expect-error - Styles won't have read only properties
73-
ref.style[key] = ''
74-
}
75-
})
76-
7770
return unistyleStyle as UnistylesValues
7871
}
7972

@@ -133,6 +126,7 @@ class UnistylesShadowRegistryBuilder {
133126
this.classNamesMap.set(ref, newClassNames)
134127
// Add new classnames to the ref
135128
ref.classList.add(...newClassNames)
129+
ref.removeAttribute('styles')
136130

137131
return newClassNames
138132
}

src/web/utils/unistyle.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
3030
}
3131

3232
export const extractSecrets = (object: any) => {
33-
return keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
33+
return object && keyInObject(object, '__uni__secrets__') ? object.__uni__secrets__ as UnistyleSecrets : undefined
3434
}
3535

3636
export const removeInlineStyles = (values: UnistylesValues) => {

0 commit comments

Comments
 (0)