feat(compiler): element codegen

This commit is contained in:
Evan You
2019-09-22 16:50:57 -04:00
parent 40307d9642
commit 3a177a18d2
15 changed files with 369 additions and 120 deletions

View File

@@ -8,15 +8,24 @@ describe('compiler: codegen', () => {
const { code, map } = generate(ast, {
filename: `foo.vue`
})
expect(code).toBe(`["hello ", world]`)
expect(code).toBe(
`return function render() {
with (this) {
return [
"hello ",
world
]
}
}`
)
expect(map!.sources).toEqual([`foo.vue`])
expect(map!.sourcesContent).toEqual([source])
const consumer = await new SourceMapConsumer(map as RawSourceMap)
const pos = consumer.originalPositionFor({
line: 1,
column: 11
line: 5,
column: 6
})
expect(pos).toMatchObject({
line: 1,