parent
be666ebd59
commit
8c17535a47
@ -194,7 +194,7 @@ function parseChildren(
|
|||||||
for (let i = 0; i < nodes.length; i++) {
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
const node = nodes[i]
|
const node = nodes[i]
|
||||||
if (node.type === NodeTypes.TEXT) {
|
if (node.type === NodeTypes.TEXT) {
|
||||||
if (!node.content.trim()) {
|
if (!/[^\t\r\n\f ]/.test(node.content)) {
|
||||||
const prev = nodes[i - 1]
|
const prev = nodes[i - 1]
|
||||||
const next = nodes[i + 1]
|
const next = nodes[i + 1]
|
||||||
// If:
|
// If:
|
||||||
@ -219,7 +219,7 @@ function parseChildren(
|
|||||||
node.content = ' '
|
node.content = ' '
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
node.content = node.content.replace(/\s+/g, ' ')
|
node.content = node.content.replace(/[\t\r\n\f ]+/g, ' ')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,9 +8,9 @@ import {
|
|||||||
InterpolationNode
|
InterpolationNode
|
||||||
} from '@vue/compiler-core'
|
} from '@vue/compiler-core'
|
||||||
import {
|
import {
|
||||||
parserOptionsMinimal as parserOptions,
|
parserOptionsStandard as parserOptions,
|
||||||
DOMNamespaces
|
DOMNamespaces
|
||||||
} from '../src/parserOptionsMinimal'
|
} from '../src/parserOptionsStandard'
|
||||||
|
|
||||||
describe('DOM parser', () => {
|
describe('DOM parser', () => {
|
||||||
describe('Text', () => {
|
describe('Text', () => {
|
||||||
@ -160,6 +160,16 @@ describe('DOM parser', () => {
|
|||||||
}
|
}
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// #945
|
||||||
|
test(' should not be condensed', () => {
|
||||||
|
const nbsp = String.fromCharCode(160)
|
||||||
|
const ast = parse(`foo bar`, parserOptions)
|
||||||
|
expect(ast.children[0]).toMatchObject({
|
||||||
|
type: NodeTypes.TEXT,
|
||||||
|
content: `foo${nbsp}${nbsp}bar`
|
||||||
|
})
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('Interpolation', () => {
|
describe('Interpolation', () => {
|
||||||
|
@ -2,6 +2,8 @@ import { ParserOptions } from '@vue/compiler-core'
|
|||||||
import { parserOptionsMinimal } from './parserOptionsMinimal'
|
import { parserOptionsMinimal } from './parserOptionsMinimal'
|
||||||
import namedCharacterReferences from './namedChars.json'
|
import namedCharacterReferences from './namedChars.json'
|
||||||
|
|
||||||
|
export { DOMNamespaces } from './parserOptionsMinimal'
|
||||||
|
|
||||||
export const parserOptionsStandard: ParserOptions = {
|
export const parserOptionsStandard: ParserOptions = {
|
||||||
// extends the minimal options with more spec-compliant overrides
|
// extends the minimal options with more spec-compliant overrides
|
||||||
...parserOptionsMinimal,
|
...parserOptionsMinimal,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user