mirror of https://github.com/vuejs/core.git
Merge a21d48de54
into ba391f5fdf
This commit is contained in:
commit
8423964a98
|
@ -7,7 +7,26 @@ exports[`compiler: parse > Edge Cases > invalid html 1`] = `
|
||||||
{
|
{
|
||||||
"children": [
|
"children": [
|
||||||
{
|
{
|
||||||
"children": [],
|
"children": [
|
||||||
|
{
|
||||||
|
"content": " ",
|
||||||
|
"loc": {
|
||||||
|
"end": {
|
||||||
|
"column": 1,
|
||||||
|
"line": 3,
|
||||||
|
"offset": 13,
|
||||||
|
},
|
||||||
|
"source": "
|
||||||
|
",
|
||||||
|
"start": {
|
||||||
|
"column": 7,
|
||||||
|
"line": 2,
|
||||||
|
"offset": 12,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"type": 2,
|
||||||
|
},
|
||||||
|
],
|
||||||
"codegenNode": undefined,
|
"codegenNode": undefined,
|
||||||
"loc": {
|
"loc": {
|
||||||
"end": {
|
"end": {
|
||||||
|
|
|
@ -2371,6 +2371,12 @@ describe('compiler: parse', () => {
|
||||||
expect((ast.children[0] as TextNode).content).toBe(` foo bar baz `)
|
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', () => {
|
test('should remove leading newline character immediately following the pre element start tag', () => {
|
||||||
const ast = parse(`<pre>\n foo bar </pre>`, {
|
const ast = parse(`<pre>\n foo bar </pre>`, {
|
||||||
isPreTag: tag => tag === 'pre',
|
isPreTag: tag => tag === 'pre',
|
||||||
|
@ -2488,6 +2494,13 @@ describe('compiler: parse', () => {
|
||||||
const ast = parse(content)
|
const ast = parse(content)
|
||||||
expect((ast.children[0] as TextNode).content).toBe(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', () => {
|
describe('expression parsing', () => {
|
||||||
|
|
|
@ -839,7 +839,8 @@ function condenseWhitespace(nodes: TemplateChildNode[]): TemplateChildNode[] {
|
||||||
const node = nodes[i]
|
const node = nodes[i]
|
||||||
if (node.type === NodeTypes.TEXT) {
|
if (node.type === NodeTypes.TEXT) {
|
||||||
if (!inPre) {
|
if (!inPre) {
|
||||||
if (isAllWhitespace(node.content)) {
|
// #7789
|
||||||
|
if (isAllWhitespace(node.content) && nodes.length > 1) {
|
||||||
const prev = nodes[i - 1] && nodes[i - 1].type
|
const prev = nodes[i - 1] && nodes[i - 1].type
|
||||||
const next = nodes[i + 1] && nodes[i + 1].type
|
const next = nodes[i + 1] && nodes[i + 1].type
|
||||||
// Remove if:
|
// Remove if:
|
||||||
|
|
|
@ -132,8 +132,7 @@ describe('transition-group', () => {
|
||||||
test('attribute fallthrough', () => {
|
test('attribute fallthrough', () => {
|
||||||
expect(
|
expect(
|
||||||
compile(
|
compile(
|
||||||
`<transition-group tag="ul" class="red" id="ok">
|
`<transition-group tag="ul" class="red" id="ok"></transition-group>`,
|
||||||
</transition-group>`,
|
|
||||||
).code,
|
).code,
|
||||||
).toMatchInlineSnapshot(`
|
).toMatchInlineSnapshot(`
|
||||||
"const { mergeProps: _mergeProps } = require("vue")
|
"const { mergeProps: _mergeProps } = require("vue")
|
||||||
|
|
Loading…
Reference in New Issue