Skip to content

Commit 77538ec

Browse files
authored
fix(runtime-dom/style): fix patchStyle on falsy next value (vuejs#1504)
fix vuejs#1506
1 parent 36b6b4f commit 77538ec

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

packages/runtime-dom/__tests__/patchStyle.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ describe(`runtime-dom: style patching`, () => {
6262
expect(el.style.getPropertyValue('margin-right')).toBe('10px')
6363
})
6464

65+
it('patch with falsy style value', () => {
66+
const el = document.createElement('div')
67+
patchProp(el as any, 'style', { width: '100px' }, { width: 0 })
68+
expect(el.style.width).toBe('0px')
69+
})
70+
6571
// JSDOM doesn't support custom properties on style object so we have to
6672
// mock it here.
6773
function mockElementWithStyle() {

packages/runtime-dom/src/modules/style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export function patchStyle(el: Element, prev: Style, next: Style) {
1717
}
1818
if (prev && !isString(prev)) {
1919
for (const key in prev) {
20-
if (!next[key]) {
20+
if (next[key] == null) {
2121
setStyle(style, key, '')
2222
}
2323
}

0 commit comments

Comments
 (0)