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

style does not work with zIndex (fix #9382) #9386

Merged
merged 1 commit into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/platforms/web/runtime/modules/style.js
Original file line number Diff line number Diff line change
@@ -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$/
Expand All @@ -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)) {
Expand Down
7 changes: 7 additions & 0 deletions test/unit/features/directives/style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down