diff options
Diffstat (limited to 'node_modules/vue/src/platforms/web/compiler/modules/style.js')
| -rw-r--r-- | node_modules/vue/src/platforms/web/compiler/modules/style.js | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/node_modules/vue/src/platforms/web/compiler/modules/style.js b/node_modules/vue/src/platforms/web/compiler/modules/style.js new file mode 100644 index 00000000..2722b92b --- /dev/null +++ b/node_modules/vue/src/platforms/web/compiler/modules/style.js @@ -0,0 +1,51 @@ +/* @flow */ + +import { parseText } from 'compiler/parser/text-parser' +import { parseStyleText } from 'web/util/style' +import { + getAndRemoveAttr, + getBindingAttr, + baseWarn +} from 'compiler/helpers' + +function transformNode (el: ASTElement, options: CompilerOptions) { + const warn = options.warn || baseWarn + const staticStyle = getAndRemoveAttr(el, 'style') + if (staticStyle) { + /* istanbul ignore if */ + if (process.env.NODE_ENV !== 'production') { + const res = parseText(staticStyle, options.delimiters) + if (res) { + warn( + `style="${staticStyle}": ` + + 'Interpolation inside attributes has been removed. ' + + 'Use v-bind or the colon shorthand instead. For example, ' + + 'instead of <div style="{{ val }}">, use <div :style="val">.' + ) + } + } + el.staticStyle = JSON.stringify(parseStyleText(staticStyle)) + } + + const styleBinding = getBindingAttr(el, 'style', false /* getStatic */) + if (styleBinding) { + el.styleBinding = styleBinding + } +} + +function genData (el: ASTElement): string { + let data = '' + if (el.staticStyle) { + data += `staticStyle:${el.staticStyle},` + } + if (el.styleBinding) { + data += `style:(${el.styleBinding}),` + } + return data +} + +export default { + staticKeys: ['staticStyle'], + transformNode, + genData +} |
