Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly update styles #12946

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/platforms/web/runtime/modules/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function updateStyle(oldVnode: VNodeWithData, vnode: VNodeWithData) {
}
for (name in newStyle) {
cur = newStyle[name]
if (cur !== oldStyle[name]) {
if (cur !== oldStyle[name] || !el.style[name]) {
// ie9 setting to null has no effect, must use empty string
setProp(el, name, cur == null ? '' : cur)
}
Expand Down
8 changes: 8 additions & 0 deletions test/unit/modules/vdom/modules/style.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ describe('vdom style module', () => {
expect(elm.style.display).toBe('block')
})

it('border related style should update correctly', () => {
const vnode1 = new VNode('p', { style: { border: '10px solid red', 'border-bottom': '10px solid blue' } })
const vnode2 = new VNode('p', { style: { 'border-right': '10px solid red', 'border-bottom': '10px solid blue' } })
patch(null, vnode1)
const elm = patch(vnode1, vnode2)
expect(elm.style.borderBottom).toBe('10px solid blue')
})

it('should remove elements attrs', () => {
const vnode1 = new VNode('p', { style: { fontSize: '12px' } })
const vnode2 = new VNode('p', { style: { display: 'block' } })
Expand Down