mirror of https://github.com/vuejs/core.git
wip: compiler-sfc should not attach ast on template with src import
This commit is contained in:
parent
e41cf8dc59
commit
37f9d3da8f
|
@ -139,7 +139,7 @@ test('should work w/ AST from descriptor', () => {
|
|||
sourceMap: true
|
||||
}).descriptor.template!
|
||||
|
||||
expect(template.ast.source).toBe(source)
|
||||
expect(template.ast!.source).toBe(source)
|
||||
|
||||
const { code, map } = compile({
|
||||
filename: 'example.vue',
|
||||
|
|
|
@ -164,6 +164,11 @@ h1 { color: red }
|
|||
expect(descriptor.script!.attrs['src']).toBe('com')
|
||||
})
|
||||
|
||||
test('should not expose ast on template node if has src import', () => {
|
||||
const { descriptor } = parse(`<template src="./foo.html"/>`)
|
||||
expect(descriptor.template!.ast).toBeUndefined()
|
||||
})
|
||||
|
||||
test('ignoreEmpty: false', () => {
|
||||
const { descriptor } = parse(
|
||||
`<script></script>\n<script setup>\n</script>`,
|
||||
|
@ -211,7 +216,7 @@ h1 { color: red }
|
|||
expect(errors.length).toBe(0)
|
||||
expect(descriptor.template!.content).toBe(content)
|
||||
// should not attempt to parse the content
|
||||
expect(descriptor.template!.ast.children.length).toBe(1)
|
||||
expect(descriptor.template!.ast!.children.length).toBe(1)
|
||||
})
|
||||
|
||||
//#2566
|
||||
|
|
|
@ -38,7 +38,7 @@ export interface SFCBlock {
|
|||
|
||||
export interface SFCTemplateBlock extends SFCBlock {
|
||||
type: 'template'
|
||||
ast: RootNode
|
||||
ast?: RootNode
|
||||
}
|
||||
|
||||
export interface SFCScriptBlock extends SFCBlock {
|
||||
|
@ -156,7 +156,10 @@ export function parse(
|
|||
source,
|
||||
false
|
||||
) as SFCTemplateBlock)
|
||||
templateBlock.ast = createRoot(node.children, source)
|
||||
|
||||
if (!templateBlock.attrs.src) {
|
||||
templateBlock.ast = createRoot(node.children, source)
|
||||
}
|
||||
|
||||
// warn against 2.x <template functional>
|
||||
if (templateBlock.attrs.functional) {
|
||||
|
|
Loading…
Reference in New Issue