Просмотр исходного кода

handle !important in static styles (fix #4306)

Evan You 9 лет назад
Родитель
Сommit
ac060163c3
1 измененных файлов с 3 добавлено и 0 удалено
  1. 3 0
      src/platforms/web/runtime/modules/style.js

+ 3 - 0
src/platforms/web/runtime/modules/style.js

@@ -4,10 +4,13 @@ import { cached, camelize, extend } from 'shared/util'
 import { normalizeStyleBinding, getStyle } from 'web/util/style'
 
 const cssVarRE = /^--/
+const importantRE = /\s*!important$/
 const setProp = (el, name, val) => {
   /* istanbul ignore if */
   if (cssVarRE.test(name)) {
     el.style.setProperty(name, val)
+  } else if (importantRE.test(val)) {
+    el.style.setProperty(name, val.replace(importantRE, ''), 'important')
   } else {
     el.style[normalize(name)] = val
   }