fix(compiler-dom): stringify eligible svg content

fix #4282
This commit is contained in:
Evan You
2021-08-09 14:39:40 -04:00
parent f258f5d2c2
commit 2641422aa7
3 changed files with 88 additions and 7 deletions

View File

@@ -360,4 +360,28 @@ describe('stringify static html', () => {
]
})
})
test('should stringify svg', () => {
const svg = `<svg width="50" height="50" viewBox="0 0 50 50" fill="none" xmlns="http://www.w3.org/2000/svg">`
const repeated = `<rect width="50" height="50" fill="#C4C4C4"></rect>`
const { ast } = compileWithStringify(
`<div>${svg}${repeat(
repeated,
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
)}</svg></div>`
)
expect(ast.hoists[0]).toMatchObject({
type: NodeTypes.JS_CALL_EXPRESSION,
callee: CREATE_STATIC,
arguments: [
JSON.stringify(
`${svg}${repeat(
repeated,
StringifyThresholds.ELEMENT_WITH_BINDING_COUNT
)}</svg>`
),
'1'
]
})
})
})