refactor: restore isSelfClosing as optional property

This commit is contained in:
Evan You 2023-11-25 22:55:39 +08:00
parent bab5bd375b
commit 157cfcb796
4 changed files with 8 additions and 0 deletions

View File

@ -3831,6 +3831,7 @@ exports[`compiler: parse > Errors > X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END > <
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 25,
@ -4417,6 +4418,7 @@ exports[`compiler: parse > self closing multiple tag 1`] = `
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 37,
@ -4497,6 +4499,7 @@ exports[`compiler: parse > self closing multiple tag 1`] = `
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 37,
@ -4611,6 +4614,7 @@ exports[`compiler: parse > valid html 1`] = `
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 39,

View File

@ -501,6 +501,7 @@ describe('compiler: parse', () => {
codegenNode: undefined,
props: [],
children: [],
isSelfClosing: true,
loc: {
start: { offset: 0, line: 1, column: 1 },
end: { offset: 6, line: 1, column: 7 },
@ -545,6 +546,7 @@ describe('compiler: parse', () => {
codegenNode: undefined,
props: [],
children: [],
isSelfClosing: true,
loc: {
start: { offset: 0, line: 1, column: 1 },
end: { offset: 6, line: 1, column: 7 },

View File

@ -131,6 +131,7 @@ export interface BaseElementNode extends Node {
tagType: ElementTypes
props: Array<AttributeNode | DirectiveNode>
children: TemplateChildNode[]
isSelfClosing?: boolean
innerLoc?: SourceLocation // only for SFC root level elements
}

View File

@ -172,6 +172,7 @@ const tokenizer = new Tokenizer(stack, {
onselfclosingtag(end) {
const name = currentOpenTag!.tag
currentOpenTag!.isSelfClosing = true
endOpenTag(end)
if (stack[0]?.tag === name) {
onCloseTag(stack.shift()!, end)