From 3c4bf7627649ec1e3220f8c4e4163c20d2afb367 Mon Sep 17 00:00:00 2001 From: Evan You Date: Fri, 13 Sep 2024 21:13:52 +0800 Subject: [PATCH] fix(compiler-dom): should ignore leading newline in ', parserOptions) + const element = ast.children[0] as ElementNode + const text = element.children[0] as TextNode + expect(element.children.length).toBe(1) + expect(text).toStrictEqual({ + type: NodeTypes.TEXT, + content: 'hello', + loc: { + start: { offset: 10, line: 1, column: 11 }, + end: { offset: 16, line: 2, column: 6 }, + source: '\nhello', + }, + }) + }) + test('should not treat Uppercase component as special tag', () => { const ast = parse( '', diff --git a/packages/compiler-dom/src/parserOptions.ts b/packages/compiler-dom/src/parserOptions.ts index e4899a9bf21..7da13bf534d 100644 --- a/packages/compiler-dom/src/parserOptions.ts +++ b/packages/compiler-dom/src/parserOptions.ts @@ -8,6 +8,7 @@ export const parserOptions: ParserOptions = { isVoidTag, isNativeTag: tag => isHTMLTag(tag) || isSVGTag(tag) || isMathMLTag(tag), isPreTag: tag => tag === 'pre', + isIgnoreNewlineTag: tag => tag === 'pre' || tag === 'textarea', decodeEntities: __BROWSER__ ? decodeHtmlBrowser : undefined, isBuiltInComponent: tag => {