diff --git a/src/platforms/web/runtime/modules/style.js b/src/platforms/web/runtime/modules/style.js index 29e1c3c1e6e..4d2d39dd6ea 100644 --- a/src/platforms/web/runtime/modules/style.js +++ b/src/platforms/web/runtime/modules/style.js @@ -1,7 +1,7 @@ /* @flow */ import { getStyle, normalizeStyleBinding } from 'web/util/style' -import { cached, camelize, extend, isDef, isUndef } from 'shared/util' +import { cached, camelize, extend, isDef, isUndef, hyphenate } from 'shared/util' const cssVarRE = /^--/ const importantRE = /\s*!important$/ @@ -10,7 +10,7 @@ const setProp = (el, name, val) => { if (cssVarRE.test(name)) { el.style.setProperty(name, val) } else if (importantRE.test(val)) { - el.style.setProperty(name, val.replace(importantRE, ''), 'important') + el.style.setProperty(hyphenate(name), val.replace(importantRE, ''), 'important') } else { const normalizedName = normalize(name) if (Array.isArray(val)) { diff --git a/test/unit/features/directives/style.spec.js b/test/unit/features/directives/style.spec.js index 43f527be71d..d611ca4a4fc 100644 --- a/test/unit/features/directives/style.spec.js +++ b/test/unit/features/directives/style.spec.js @@ -101,6 +101,13 @@ describe('Directive v-bind:style', () => { }).then(done) }) + it('camelCase with !important', done => { + vm.styles = { zIndex: '100 !important' } + waitForUpdate(() => { + expect(vm.$el.style.getPropertyPriority('z-index')).toBe('important') + }).then(done) + }) + it('object with multiple entries', done => { vm.$el.style.color = 'red' vm.styles = {