feat(compiler): preserve whitespace in pre tag, add tests
This commit is contained in:
@@ -98,6 +98,15 @@ describe('DOM parser', () => {
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
test('<pre> tag should preserve raw whitespace', () => {
|
||||
const rawText = ` \na b \n c`
|
||||
const ast = parse(`<pre>${rawText}</pre>`, parserOptions)
|
||||
expect((ast.children[0] as ElementNode).children[0]).toMatchObject({
|
||||
type: NodeTypes.TEXT,
|
||||
content: rawText
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Interpolation', () => {
|
||||
|
||||
@@ -15,8 +15,8 @@ export const enum DOMNamespaces {
|
||||
|
||||
export const parserOptionsMinimal: ParserOptions = {
|
||||
isVoidTag,
|
||||
|
||||
isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag),
|
||||
isPreTag: tag => tag === 'pre',
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/parsing.html#tree-construction-dispatcher
|
||||
getNamespace(tag: string, parent: ElementNode | undefined): DOMNamespaces {
|
||||
|
||||
Reference in New Issue
Block a user