Skip to content

Commit 50814b3

Browse files
committed
Update: add selfClosing flag
1 parent e5213a4 commit 50814b3

File tree

78 files changed

+235
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+235
-0
lines changed

src/ast/nodes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ export interface VDirective extends HasLocation, HasParent {
683683
export interface VStartTag extends HasLocation, HasParent {
684684
type: "VStartTag"
685685
parent: VElement
686+
selfClosing: boolean
686687
attributes: (VAttribute | VDirective)[]
687688
}
688689

src/html/parser.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ export class Parser {
351351
range: token.range,
352352
loc: token.loc,
353353
parent: DUMMY_PARENT,
354+
selfClosing: token.selfClosing,
354355
attributes: token.attributes,
355356
},
356357
children: [],

test/fixtures/ast/attributes/ast.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 11
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": [
115117
{
116118
"type": "VAttribute",
@@ -225,6 +227,7 @@
225227
"column": 12
226228
}
227229
},
230+
"selfClosing": false,
228231
"attributes": [
229232
{
230233
"type": "VAttribute",
@@ -339,6 +342,7 @@
339342
"column": 13
340343
}
341344
},
345+
"selfClosing": false,
342346
"attributes": [
343347
{
344348
"type": "VAttribute",
@@ -470,6 +474,7 @@
470474
"column": 14
471475
}
472476
},
477+
"selfClosing": false,
473478
"attributes": [
474479
{
475480
"type": "VAttribute",
@@ -601,6 +606,7 @@
601606
"column": 15
602607
}
603608
},
609+
"selfClosing": false,
604610
"attributes": [
605611
{
606612
"type": "VAttribute",
@@ -732,6 +738,7 @@
732738
"column": 15
733739
}
734740
},
741+
"selfClosing": false,
735742
"attributes": [
736743
{
737744
"type": "VAttribute",

test/fixtures/ast/auto-closing-dt-dd/ast.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 8
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": []
115117
},
116118
"children": [
@@ -167,6 +169,7 @@
167169
"column": 12
168170
}
169171
},
172+
"selfClosing": false,
170173
"attributes": []
171174
},
172175
"children": [
@@ -227,6 +230,7 @@
227230
"column": 12
228231
}
229232
},
233+
"selfClosing": false,
230234
"attributes": []
231235
},
232236
"children": [
@@ -287,6 +291,7 @@
287291
"column": 12
288292
}
289293
},
294+
"selfClosing": false,
290295
"attributes": []
291296
},
292297
"children": [
@@ -347,6 +352,7 @@
347352
"column": 12
348353
}
349354
},
355+
"selfClosing": false,
350356
"attributes": []
351357
},
352358
"children": [

test/fixtures/ast/auto-closing-p/ast.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 7
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": []
115117
},
116118
"children": [
@@ -171,6 +173,7 @@
171173
"column": 7
172174
}
173175
},
176+
"selfClosing": false,
174177
"attributes": []
175178
},
176179
"children": [
@@ -231,6 +234,7 @@
231234
"column": 8
232235
}
233236
},
237+
"selfClosing": false,
234238
"attributes": []
235239
},
236240
"children": [],
@@ -290,6 +294,7 @@
290294
"column": 7
291295
}
292296
},
297+
"selfClosing": false,
293298
"attributes": []
294299
},
295300
"children": [
@@ -350,6 +355,7 @@
350355
"column": 9
351356
}
352357
},
358+
"selfClosing": false,
353359
"attributes": []
354360
},
355361
"children": [],

test/fixtures/ast/bogus-comments/ast.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [

test/fixtures/ast/cdata/ast.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 56
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": [
115117
{
116118
"type": "VAttribute",
@@ -333,6 +335,7 @@
333335
"column": 15
334336
}
335337
},
338+
"selfClosing": false,
336339
"attributes": []
337340
},
338341
"children": [
@@ -427,6 +430,7 @@
427430
"column": 33
428431
}
429432
},
433+
"selfClosing": true,
430434
"attributes": [
431435
{
432436
"type": "VAttribute",

test/fixtures/ast/comments-2/ast.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [

test/fixtures/ast/comments/ast.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -129,6 +130,7 @@
129130
"column": 9
130131
}
131132
},
133+
"selfClosing": false,
132134
"attributes": []
133135
},
134136
"children": [
@@ -241,6 +243,7 @@
241243
"column": 9
242244
}
243245
},
246+
"selfClosing": false,
244247
"attributes": []
245248
},
246249
"children": [

test/fixtures/ast/custom-thead/ast.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 11
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": []
115117
},
116118
"children": [
@@ -167,6 +169,7 @@
167169
"column": 22
168170
}
169171
},
172+
"selfClosing": false,
170173
"attributes": []
171174
},
172175
"children": [],

test/fixtures/ast/directive-argument-and-modifiers/ast.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 17
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": [
115117
{
116118
"type": "VAttribute",
@@ -236,6 +238,7 @@
236238
"column": 19
237239
}
238240
},
241+
"selfClosing": false,
239242
"attributes": [
240243
{
241244
"type": "VAttribute",

test/fixtures/ast/directive-arguments/ast.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 15
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": [
115117
{
116118
"type": "VAttribute",
@@ -232,6 +234,7 @@
232234
"column": 16
233235
}
234236
},
237+
"selfClosing": false,
235238
"attributes": [
236239
{
237240
"type": "VAttribute",
@@ -353,6 +356,7 @@
353356
"column": 17
354357
}
355358
},
359+
"selfClosing": false,
356360
"attributes": [
357361
{
358362
"type": "VAttribute",

test/fixtures/ast/directive-modifiers/ast.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 15
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": [
115117
{
116118
"type": "VAttribute",
@@ -236,6 +238,7 @@
236238
"column": 17
237239
}
238240
},
241+
"selfClosing": false,
239242
"attributes": [
240243
{
241244
"type": "VAttribute",
@@ -422,6 +425,7 @@
422425
"column": 19
423426
}
424427
},
428+
"selfClosing": false,
425429
"attributes": [
426430
{
427431
"type": "VAttribute",

test/fixtures/ast/directive-shorthands/ast.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"column": 10
5656
}
5757
},
58+
"selfClosing": false,
5859
"attributes": []
5960
},
6061
"children": [
@@ -111,6 +112,7 @@
111112
"column": 14
112113
}
113114
},
115+
"selfClosing": false,
114116
"attributes": [
115117
{
116118
"type": "VAttribute",
@@ -236,6 +238,7 @@
236238
"column": 14
237239
}
238240
},
241+
"selfClosing": false,
239242
"attributes": [
240243
{
241244
"type": "VAttribute",

0 commit comments

Comments
 (0)