Skip to content

Commit

Permalink
fix(compiler-ssr): keep the order of imports expression for the fallb…
Browse files Browse the repository at this point in the history
…ack branch of SSR (#3448)

fix #3447
  • Loading branch information
HcySunYang committed Mar 25, 2021
1 parent 7769513 commit 49f4072
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/compiler-sfc/__tests__/compileTemplate.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,19 @@ test('preprocessor errors', () => {
`The end of the string reached with no closing bracket ) found.`
)
})

// #3447
test('should generate the correct imports expression', () => {
const { code } = compile({
filename: 'example.vue',
source: `
<img src="./foo.svg"/>
<Comp>
<img src="./bar.svg"/>
</Comp>
`,
ssr: true
})
expect(code).toMatch(`_ssrRenderAttr(\"src\", _imports_1)`)
expect(code).toMatch(`_createVNode(\"img\", { src: _imports_1 })`)
})
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,7 @@ function subTransform(
// inherit parent scope analysis state
childContext.scopes = { ...parentContext.scopes }
childContext.identifiers = { ...parentContext.identifiers }
childContext.imports = parentContext.imports
// traverse
traverseNode(childRoot, childContext)
// merge helpers/components/directives into parent context
Expand Down

0 comments on commit 49f4072

Please sign in to comment.