Skip to content

Commit dac2f6d

Browse files
committed
fix IE9 inline styles with prefix (fix vuejs#2567)
1 parent 89b4ee9 commit dac2f6d

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

src/directives/internal/style.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
extend,
33
isArray,
44
hyphenate,
5-
camelize
5+
camelize,
6+
warn
67
} from '../../util/index'
78

89
const prefixes = ['-webkit-', '-moz-', '-ms-']
@@ -56,11 +57,20 @@ export default {
5657
? 'important'
5758
: ''
5859
if (isImportant) {
60+
/* istanbul ignore if */
61+
if (process.env.NODE_ENV !== 'production') {
62+
warn(
63+
'It\'s probably a bad idea to use !important with inline rules. ' +
64+
'This feature will be deprecated in a future version of Vue.'
65+
)
66+
}
5967
value = value.replace(importantRE, '').trim()
68+
this.el.style.setProperty(prop.kebab, value, isImportant)
69+
} else {
70+
this.el.style[prop.camel] = value
6071
}
61-
this.el.style.setProperty(prop, value, isImportant)
6272
} else {
63-
this.el.style.removeProperty(prop)
73+
this.el.style[prop.camel] = ''
6474
}
6575
}
6676

@@ -105,10 +115,16 @@ function prefix (prop) {
105115
while (i--) {
106116
prefixed = camelPrefixes[i] + upper
107117
if (prefixed in testEl.style) {
108-
return prefixes[i] + prop
118+
return {
119+
kebab: prefixes[i] + prop,
120+
camel: prefixed
121+
}
109122
}
110123
}
111124
if (camel in testEl.style) {
112-
return prop
125+
return {
126+
kebab: prop,
127+
camel: camel
128+
}
113129
}
114130
}

0 commit comments

Comments
 (0)