Skip to content
Permalink
Browse files
fix(runtime-dom): properly handle style properties with undefined val…
…ues (#5348)

fix #5322
  • Loading branch information
LinusBorg committed Apr 13, 2022
1 parent f4d2c9f commit 85af1398637ee91c6ebabb73bf42250320311e19
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
@@ -37,7 +37,18 @@ describe(`runtime-dom: style patching`, () => {

it('remove if falsy value', () => {
const el = document.createElement('div')
patchProp(el, 'style', { color: 'red' }, { color: undefined })
patchProp(el, 'style', null, {
color: undefined,
borderRadius: null
})
expect(el.style.cssText.replace(/\s/g, '')).toBe('')

patchProp(
el,
'style',
{ color: 'red' },
{ color: null, borderRadius: undefined }
)
expect(el.style.cssText.replace(/\s/g, '')).toBe('')
})

@@ -45,6 +45,7 @@ function setStyle(
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)

0 comments on commit 85af139

Please sign in to comment.