fix(compiler-core): should not condense whitespace in RCDATA text mode (#3482)
fix #3479
This commit is contained in:
parent
6e88156934
commit
b4b82159e2
@ -1812,6 +1812,16 @@ foo
|
||||
`\n foo bar `
|
||||
)
|
||||
})
|
||||
|
||||
it('should NOT condense whitespaces in RCDATA text mode', () => {
|
||||
const ast = baseParse(`<textarea>Text:\n foo</textarea>`, {
|
||||
getTextMode: ({ tag }) =>
|
||||
tag === 'textarea' ? TextModes.RCDATA : TextModes.DATA
|
||||
})
|
||||
const preElement = ast.children[0] as ElementNode
|
||||
expect(preElement.children).toHaveLength(1)
|
||||
expect((preElement.children[0] as TextNode).content).toBe(`Text:\n foo`)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Errors', () => {
|
||||
|
@ -205,7 +205,7 @@ function parseChildren(
|
||||
// Whitespace management for more efficient output
|
||||
// (same as v2 whitespace: 'condense')
|
||||
let removedWhitespace = false
|
||||
if (mode !== TextModes.RAWTEXT) {
|
||||
if (mode !== TextModes.RAWTEXT && mode !== TextModes.RCDATA) {
|
||||
for (let i = 0; i < nodes.length; i++) {
|
||||
const node = nodes[i]
|
||||
if (!context.inPre && node.type === NodeTypes.TEXT) {
|
||||
|
Loading…
Reference in New Issue
Block a user