Skip to content

Commit 24b7a57

Browse files
Filipe AmaralLostlover
Filipe Amaral
authored andcommitted
fix: fix v-bind:style for camelCase properties with !important (vuejs#9386)
1 parent c4a3f15 commit 24b7a57

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

src/platforms/web/runtime/modules/style.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* @flow */
22

33
import { getStyle, normalizeStyleBinding } from 'web/util/style'
4-
import { cached, camelize, extend, isDef, isUndef } from 'shared/util'
4+
import { cached, camelize, extend, isDef, isUndef, hyphenate } from 'shared/util'
55

66
const cssVarRE = /^--/
77
const importantRE = /\s*!important$/
@@ -10,7 +10,7 @@ const setProp = (el, name, val) => {
1010
if (cssVarRE.test(name)) {
1111
el.style.setProperty(name, val)
1212
} else if (importantRE.test(val)) {
13-
el.style.setProperty(name, val.replace(importantRE, ''), 'important')
13+
el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important')
1414
} else {
1515
const normalizedName = normalize(name)
1616
if (Array.isArray(val)) {

test/unit/features/directives/style.spec.js

+7
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ describe('Directive v-bind:style', () => {
101101
}).then(done)
102102
})
103103

104+
it('camelCase with !important', done => {
105+
vm.styles = { zIndex: '100 !important' }
106+
waitForUpdate(() => {
107+
expect(vm.$el.style.getPropertyPriority('z-index')).toBe('important')
108+
}).then(done)
109+
})
110+
104111
it('object with multiple entries', done => {
105112
vm.$el.style.color = 'red'
106113
vm.styles = {

0 commit comments

Comments
 (0)