Skip to content

Commit

Permalink
fix(cli): fixed priority of "+" operator for bindStyle
Browse files Browse the repository at this point in the history
  • Loading branch information
deepfunc committed Sep 30, 2019
1 parent 0ff8eaf commit cb13407
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/cli/core/plugins/template/attrs/bindStyle.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
const exprParser = require('../../../util/exprParser');

exports = module.exports = function () {

this.register('template-parse-ast-attr-:style', function parseBindClass ({item, name, expr}) {
this.register('template-parse-ast-attr-:style', function parseBindStyle({ item, name, expr }) {
let exprObj = exprParser.str2obj(expr);
item.bindStyle = Object.keys(exprObj).map(name => {
let exp = exprObj[name].replace(/\'/ig, '\\\'').replace(/\"/ig, '\\"');

// add brackets to fix priority of "+" operator.
if (/^\(.*\)$/.test(exp) === false) {
exp = `(${exp})`;
}
name = name.replace(/\'/ig, '\\\'').replace(/\"/ig, '\\"');
name = exprParser.hyphenate(name);
return `'${name}:' + ${exp} + ';'`;
Expand Down

0 comments on commit cb13407

Please sign in to comment.