Skip to content

Commit

Permalink
fix: toSource render params
Browse files Browse the repository at this point in the history
  • Loading branch information
meixg committed Dec 3, 2021
1 parent d0c6885 commit 631483e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/target-js/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,13 @@ export default class ToJSCompiler implements TargetCodeGenerator {
if (options.bareFunctionBody) {
emitter.writeLine('let exports = {}, module = { exports };')
this.doCompileToSource(sourceFile, options, emitter)
emitter.writeLine('return module.exports(data, noDataOutput);')
emitter.writeLine('return module.exports(data, {noDataOutput});')
} else if (options.bareFunction) {
emitter.writeFunction('render', ['data', 'noDataOutput'], () => {
emitter.writeFunction('render', ['data', 'info'], () => {
emitter.writeLine('let noDataOutput = info && info.noDataOutput;')
emitter.writeLine('let exports = {}, module = { exports };')
this.doCompileToSource(sourceFile, options, emitter)
emitter.writeLine('return module.exports(data, noDataOutput);')
emitter.writeLine('return module.exports(data, {noDataOutput});')
})
} else {
this.doCompileToSource(sourceFile, options, emitter)
Expand Down
2 changes: 1 addition & 1 deletion test/unit/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe('compileToSource', function () {
const code = compileToSource(ComponentClass as any)

expect(code).toContain('html += "A')
expect(code).toMatch(/^function render \(data, noDataOutput\) {/)
expect(code).toMatch(/^function render \(data, info\) {/)
})
})

Expand Down

0 comments on commit 631483e

Please sign in to comment.