fix(compiler-core): force <svg> into blocks for correct runtime isSVG

state during patch
This commit is contained in:
Evan You
2020-01-20 14:48:19 -05:00
parent 0c42a6d8fa
commit f2ac28b31e
3 changed files with 48 additions and 7 deletions

View File

@@ -16,7 +16,9 @@ import {
RESOLVE_DYNAMIC_COMPONENT,
SUSPENSE,
KEEP_ALIVE,
BASE_TRANSITION
BASE_TRANSITION,
OPEN_BLOCK,
CREATE_BLOCK
} from '../../src/runtimeHelpers'
import {
CallExpression,
@@ -821,4 +823,25 @@ describe('compiler: element transform', () => {
])
})
})
test('<svg> should be forced into blocks', () => {
const ast = parse(`<div><svg/></div>`)
transform(ast, {
nodeTransforms: [transformElement]
})
expect((ast as any).children[0].children[0].codegenNode).toMatchObject({
type: NodeTypes.JS_SEQUENCE_EXPRESSION,
expressions: [
{
type: NodeTypes.JS_CALL_EXPRESSION,
callee: OPEN_BLOCK
},
{
type: NodeTypes.JS_CALL_EXPRESSION,
callee: CREATE_BLOCK,
arguments: [`"svg"`]
}
]
})
})
})