Skip to content

Commit 157cfcb

Browse files
committed
refactor: restore isSelfClosing as optional property
1 parent bab5bd3 commit 157cfcb

File tree

4 files changed

+8
-0
lines changed

4 files changed

+8
-0
lines changed

packages/compiler-core/__tests__/__snapshots__/parse.spec.ts.snap

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3831,6 +3831,7 @@ exports[`compiler: parse > Errors > X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END > <
38313831
{
38323832
"children": [],
38333833
"codegenNode": undefined,
3834+
"isSelfClosing": true,
38343835
"loc": {
38353836
"end": {
38363837
"column": 25,
@@ -4417,6 +4418,7 @@ exports[`compiler: parse > self closing multiple tag 1`] = `
44174418
{
44184419
"children": [],
44194420
"codegenNode": undefined,
4421+
"isSelfClosing": true,
44204422
"loc": {
44214423
"end": {
44224424
"column": 37,
@@ -4497,6 +4499,7 @@ exports[`compiler: parse > self closing multiple tag 1`] = `
44974499
{
44984500
"children": [],
44994501
"codegenNode": undefined,
4502+
"isSelfClosing": true,
45004503
"loc": {
45014504
"end": {
45024505
"column": 37,
@@ -4611,6 +4614,7 @@ exports[`compiler: parse > valid html 1`] = `
46114614
{
46124615
"children": [],
46134616
"codegenNode": undefined,
4617+
"isSelfClosing": true,
46144618
"loc": {
46154619
"end": {
46164620
"column": 39,

packages/compiler-core/__tests__/parse.spec.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ describe('compiler: parse', () => {
501501
codegenNode: undefined,
502502
props: [],
503503
children: [],
504+
isSelfClosing: true,
504505
loc: {
505506
start: { offset: 0, line: 1, column: 1 },
506507
end: { offset: 6, line: 1, column: 7 },
@@ -545,6 +546,7 @@ describe('compiler: parse', () => {
545546
codegenNode: undefined,
546547
props: [],
547548
children: [],
549+
isSelfClosing: true,
548550
loc: {
549551
start: { offset: 0, line: 1, column: 1 },
550552
end: { offset: 6, line: 1, column: 7 },

packages/compiler-core/src/ast.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ export interface BaseElementNode extends Node {
131131
tagType: ElementTypes
132132
props: Array<AttributeNode | DirectiveNode>
133133
children: TemplateChildNode[]
134+
isSelfClosing?: boolean
134135
innerLoc?: SourceLocation // only for SFC root level elements
135136
}
136137

packages/compiler-core/src/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ const tokenizer = new Tokenizer(stack, {
172172

173173
onselfclosingtag(end) {
174174
const name = currentOpenTag!.tag
175+
currentOpenTag!.isSelfClosing = true
175176
endOpenTag(end)
176177
if (stack[0]?.tag === name) {
177178
onCloseTag(stack.shift()!, end)

0 commit comments

Comments
 (0)