mirror of https://github.com/vuejs/core.git
Merge a21d48de54
into 56be3dd4db
This commit is contained in:
commit
09acc4d6c2
|
@ -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": {
|
||||
|
|
|
@ -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', () => {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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")
|
||||
|
|
Loading…
Reference in New Issue