This commit is contained in:
Rudy 2025-05-05 20:41:53 +00:00 committed by GitHub
commit 09acc4d6c2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 4 deletions

View File

@ -7,7 +7,26 @@ exports[`compiler: parse > Edge Cases > invalid html 1`] = `
{
"children": [
{
"children": [],
"children": [
{
"content": " ",
"loc": {
"end": {
"column": 1,
"line": 3,
"offset": 13,
},
"source": "
",
"start": {
"column": 7,
"line": 2,
"offset": 12,
},
},
"type": 2,
},
],
"codegenNode": undefined,
"loc": {
"end": {

View File

@ -2366,6 +2366,12 @@ describe('compiler: parse', () => {
expect((ast.children[0] as TextNode).content).toBe(` foo bar baz `)
})
// #7789
test('should condense consecutive whitespaces in texts full of whitespaces', () => {
const ast = parse(` `)
expect((ast.children[0] as TextNode).content).toBe(` `)
})
test('should remove leading newline character immediately following the pre element start tag', () => {
const ast = parse(`<pre>\n foo bar </pre>`, {
isPreTag: tag => tag === 'pre',
@ -2483,6 +2489,13 @@ describe('compiler: parse', () => {
const ast = parse(content)
expect((ast.children[0] as TextNode).content).toBe(content)
})
// #7789
test('should preserve consecutive whitespaces in texts full of whitespaces', () => {
const whitespaces = ' '
const ast = parse(`${whitespaces}`)
expect((ast.children[0] as TextNode).content).toBe(whitespaces)
})
})
describe('expression parsing', () => {

View File

@ -842,7 +842,8 @@ function condenseWhitespace(
const node = nodes[i]
if (node.type === NodeTypes.TEXT) {
if (!inPre) {
if (isAllWhitespace(node.content)) {
// #7789
if (isAllWhitespace(node.content) && nodes.length > 1) {
const prev = nodes[i - 1] && nodes[i - 1].type
const next = nodes[i + 1] && nodes[i + 1].type
// Remove if:

View File

@ -132,8 +132,7 @@ describe('transition-group', () => {
test('attribute fallthrough', () => {
expect(
compile(
`<transition-group tag="ul" class="red" id="ok">
</transition-group>`,
`<transition-group tag="ul" class="red" id="ok"></transition-group>`,
).code,
).toMatchInlineSnapshot(`
"const { mergeProps: _mergeProps } = require("vue")