Skip to content

Commit

Permalink
refactor: restore isSelfClosing as optional property
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Nov 25, 2023
1 parent bab5bd3 commit 157cfcb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3831,6 +3831,7 @@ exports[`compiler: parse > Errors > X_MISSING_DYNAMIC_DIRECTIVE_ARGUMENT_END > <
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 25,
Expand Down Expand Up @@ -4417,6 +4418,7 @@ exports[`compiler: parse > self closing multiple tag 1`] = `
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 37,
Expand Down Expand Up @@ -4497,6 +4499,7 @@ exports[`compiler: parse > self closing multiple tag 1`] = `
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 37,
Expand Down Expand Up @@ -4611,6 +4614,7 @@ exports[`compiler: parse > valid html 1`] = `
{
"children": [],
"codegenNode": undefined,
"isSelfClosing": true,
"loc": {
"end": {
"column": 39,
Expand Down
2 changes: 2 additions & 0 deletions packages/compiler-core/__tests__/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down Expand Up @@ -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 },
Expand Down
1 change: 1 addition & 0 deletions packages/compiler-core/src/ast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions packages/compiler-core/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 157cfcb

Please sign in to comment.