Skip to content

Commit

Permalink
fix: do not handle false + move into lower branch
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Apr 13, 2022
1 parent 4f2deb3 commit 59a6eb5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/runtime-dom/__tests__/patchStyle.spec.ts
Expand Up @@ -39,15 +39,15 @@ describe(`runtime-dom: style patching`, () => {
const el = document.createElement('div')
patchProp(el, 'style', null, {
color: undefined,
'--color': false,
borderRadius: null
})
expect(el.style.cssText.replace(/\s/g, '')).toBe('')

patchProp(
el,
'style',
{ color: 'red' },
{ color: undefined, '--color': false, borderRadius: false }
{ color: null, borderRadius: undefined }
)
expect(el.style.cssText.replace(/\s/g, '')).toBe('')
})
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime-dom/src/modules/style.ts
Expand Up @@ -42,10 +42,10 @@ function setStyle(
name: string,
val: string | string[]
) {
val = val == null || (val as any) === false ? '' : val
if (isArray(val)) {
val.forEach(v => setStyle(style, name, v))
} else {
if (val == null) val = ''
if (name.startsWith('--')) {
// custom property definition
style.setProperty(name, val)
Expand Down

0 comments on commit 59a6eb5

Please sign in to comment.