Skip to content

Commit

Permalink
fix: component attr string interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Nov 7, 2022
1 parent 615d991 commit 3f0ffac
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/render-by-source.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function renderBySource (caseName) {
}

const render = require(join(caseRoot, `${caseName}/output/ssr.js`))
const html = render(...getRenderArguments(caseName, caseRoot, ssrSpec.info || {}))
const html = render(...getRenderArguments(caseName, caseRoot, ssrSpec?.info || {}))

return html
}
Expand Down
1 change: 0 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"mkdirp": "^1.0.4",
"mustache": "^4.0.1",
"san": "^3.12.0",
"san-html-cases": "^3.12.3",
"san-html-cases": "^3.12.4",
"san-ssr-target-fake-cmd": "^1.0.0",
"san-ssr-target-fake-esm": "^1.0.0",
"source-map-support": "^0.5.19",
Expand Down
9 changes: 9 additions & 0 deletions src/target-js/js-emitter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ export class JSEmitter extends Emitter {
this.write('[')
this.writeSyntaxNode(node.rhs)
this.write(']')
} else if (node.op === '+') {
// + 可能是字符串拼接,也可能是数值加法。涉及到类型转换,因此需要特殊处理,
// 例如 "index is: {{index + 1}}",
// 不能输出为 "index is: " + index + 1,而应该是 "index is: " + (index + 1)
this.writeSyntaxNode(node.lhs)
this.write(` ${node.op} `)
this.write('(')
this.writeSyntaxNode(node.rhs)
this.write(')')
} else {
this.writeSyntaxNode(node.lhs)
this.write(` ${node.op} `)
Expand Down

0 comments on commit 3f0ffac

Please sign in to comment.