Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 40039f1

Browse files
committedMar 19, 2025·
fix: text token type in V_EXPRESSION_DATA state
1 parent 9574d91 commit 40039f1

File tree

5 files changed

+567
-2
lines changed

5 files changed

+567
-2
lines changed
 

‎src/html/tokenizer.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,9 +1892,9 @@ export class Tokenizer {
18921892
const type = isWhitespace(cp)
18931893
? "HTMLWhitespace"
18941894
: state === "RCDATA"
1895-
? "HTMLRawText"
1895+
? "HTMLRCDataText"
18961896
: state === "RAWTEXT"
1897-
? "HTMLRCDataText"
1897+
? "HTMLRawText"
18981898
: "HTMLText"
18991899
if (this.currentToken != null && this.currentToken.type !== type) {
19001900
this.endToken()
Lines changed: 495 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,495 @@
1+
{
2+
"type": "Program",
3+
"start": 0,
4+
"end": 0,
5+
"loc": {
6+
"start": {
7+
"line": 1,
8+
"column": 0
9+
},
10+
"end": {
11+
"line": 1,
12+
"column": 0
13+
}
14+
},
15+
"range": [
16+
0,
17+
0
18+
],
19+
"body": [],
20+
"sourceType": "module",
21+
"comments": [],
22+
"tokens": [],
23+
"templateBody": {
24+
"type": "VElement",
25+
"range": [
26+
0,
27+
59
28+
],
29+
"loc": {
30+
"start": {
31+
"line": 1,
32+
"column": 0
33+
},
34+
"end": {
35+
"line": 3,
36+
"column": 11
37+
}
38+
},
39+
"name": "template",
40+
"rawName": "template",
41+
"namespace": "http://www.w3.org/1999/xhtml",
42+
"startTag": {
43+
"type": "VStartTag",
44+
"range": [
45+
0,
46+
10
47+
],
48+
"loc": {
49+
"start": {
50+
"line": 1,
51+
"column": 0
52+
},
53+
"end": {
54+
"line": 1,
55+
"column": 10
56+
}
57+
},
58+
"selfClosing": false,
59+
"attributes": []
60+
},
61+
"children": [
62+
{
63+
"type": "VText",
64+
"range": [
65+
10,
66+
15
67+
],
68+
"loc": {
69+
"start": {
70+
"line": 1,
71+
"column": 10
72+
},
73+
"end": {
74+
"line": 2,
75+
"column": 4
76+
}
77+
},
78+
"value": "\n "
79+
},
80+
{
81+
"type": "VElement",
82+
"range": [
83+
15,
84+
47
85+
],
86+
"loc": {
87+
"start": {
88+
"line": 2,
89+
"column": 4
90+
},
91+
"end": {
92+
"line": 2,
93+
"column": 36
94+
}
95+
},
96+
"name": "textarea",
97+
"rawName": "textarea",
98+
"namespace": "http://www.w3.org/1999/xhtml",
99+
"startTag": {
100+
"type": "VStartTag",
101+
"range": [
102+
15,
103+
25
104+
],
105+
"loc": {
106+
"start": {
107+
"line": 2,
108+
"column": 4
109+
},
110+
"end": {
111+
"line": 2,
112+
"column": 14
113+
}
114+
},
115+
"selfClosing": false,
116+
"attributes": []
117+
},
118+
"children": [
119+
{
120+
"type": "VExpressionContainer",
121+
"range": [
122+
25,
123+
36
124+
],
125+
"loc": {
126+
"start": {
127+
"line": 2,
128+
"column": 14
129+
},
130+
"end": {
131+
"line": 2,
132+
"column": 25
133+
}
134+
},
135+
"expression": null,
136+
"references": []
137+
}
138+
],
139+
"endTag": {
140+
"type": "VEndTag",
141+
"range": [
142+
36,
143+
47
144+
],
145+
"loc": {
146+
"start": {
147+
"line": 2,
148+
"column": 25
149+
},
150+
"end": {
151+
"line": 2,
152+
"column": 36
153+
}
154+
}
155+
},
156+
"variables": []
157+
},
158+
{
159+
"type": "VText",
160+
"range": [
161+
47,
162+
48
163+
],
164+
"loc": {
165+
"start": {
166+
"line": 2,
167+
"column": 36
168+
},
169+
"end": {
170+
"line": 3,
171+
"column": 0
172+
}
173+
},
174+
"value": "\n"
175+
}
176+
],
177+
"endTag": {
178+
"type": "VEndTag",
179+
"range": [
180+
48,
181+
59
182+
],
183+
"loc": {
184+
"start": {
185+
"line": 3,
186+
"column": 0
187+
},
188+
"end": {
189+
"line": 3,
190+
"column": 11
191+
}
192+
}
193+
},
194+
"variables": [],
195+
"tokens": [
196+
{
197+
"type": "HTMLTagOpen",
198+
"range": [
199+
0,
200+
9
201+
],
202+
"loc": {
203+
"start": {
204+
"line": 1,
205+
"column": 0
206+
},
207+
"end": {
208+
"line": 1,
209+
"column": 9
210+
}
211+
},
212+
"value": "template"
213+
},
214+
{
215+
"type": "HTMLTagClose",
216+
"range": [
217+
9,
218+
10
219+
],
220+
"loc": {
221+
"start": {
222+
"line": 1,
223+
"column": 9
224+
},
225+
"end": {
226+
"line": 1,
227+
"column": 10
228+
}
229+
},
230+
"value": ""
231+
},
232+
{
233+
"type": "HTMLWhitespace",
234+
"range": [
235+
10,
236+
15
237+
],
238+
"loc": {
239+
"start": {
240+
"line": 1,
241+
"column": 10
242+
},
243+
"end": {
244+
"line": 2,
245+
"column": 4
246+
}
247+
},
248+
"value": "\n "
249+
},
250+
{
251+
"type": "HTMLTagOpen",
252+
"range": [
253+
15,
254+
24
255+
],
256+
"loc": {
257+
"start": {
258+
"line": 2,
259+
"column": 4
260+
},
261+
"end": {
262+
"line": 2,
263+
"column": 13
264+
}
265+
},
266+
"value": "textarea"
267+
},
268+
{
269+
"type": "HTMLTagClose",
270+
"range": [
271+
24,
272+
25
273+
],
274+
"loc": {
275+
"start": {
276+
"line": 2,
277+
"column": 13
278+
},
279+
"end": {
280+
"line": 2,
281+
"column": 14
282+
}
283+
},
284+
"value": ""
285+
},
286+
{
287+
"type": "VExpressionStart",
288+
"range": [
289+
25,
290+
27
291+
],
292+
"loc": {
293+
"start": {
294+
"line": 2,
295+
"column": 14
296+
},
297+
"end": {
298+
"line": 2,
299+
"column": 16
300+
}
301+
},
302+
"value": "{{"
303+
},
304+
{
305+
"type": "HTMLRCDataText",
306+
"range": [
307+
27,
308+
30
309+
],
310+
"loc": {
311+
"start": {
312+
"line": 2,
313+
"column": 16
314+
},
315+
"end": {
316+
"line": 2,
317+
"column": 19
318+
}
319+
},
320+
"value": "foo"
321+
},
322+
{
323+
"type": "HTMLWhitespace",
324+
"range": [
325+
30,
326+
31
327+
],
328+
"loc": {
329+
"start": {
330+
"line": 2,
331+
"column": 19
332+
},
333+
"end": {
334+
"line": 2,
335+
"column": 20
336+
}
337+
},
338+
"value": " "
339+
},
340+
{
341+
"type": "HTMLRCDataText",
342+
"range": [
343+
31,
344+
34
345+
],
346+
"loc": {
347+
"start": {
348+
"line": 2,
349+
"column": 20
350+
},
351+
"end": {
352+
"line": 2,
353+
"column": 23
354+
}
355+
},
356+
"value": "bar"
357+
},
358+
{
359+
"type": "VExpressionEnd",
360+
"range": [
361+
34,
362+
36
363+
],
364+
"loc": {
365+
"start": {
366+
"line": 2,
367+
"column": 23
368+
},
369+
"end": {
370+
"line": 2,
371+
"column": 25
372+
}
373+
},
374+
"value": "}}"
375+
},
376+
{
377+
"type": "HTMLEndTagOpen",
378+
"range": [
379+
36,
380+
46
381+
],
382+
"loc": {
383+
"start": {
384+
"line": 2,
385+
"column": 25
386+
},
387+
"end": {
388+
"line": 2,
389+
"column": 35
390+
}
391+
},
392+
"value": "textarea"
393+
},
394+
{
395+
"type": "HTMLTagClose",
396+
"range": [
397+
46,
398+
47
399+
],
400+
"loc": {
401+
"start": {
402+
"line": 2,
403+
"column": 35
404+
},
405+
"end": {
406+
"line": 2,
407+
"column": 36
408+
}
409+
},
410+
"value": ""
411+
},
412+
{
413+
"type": "HTMLWhitespace",
414+
"range": [
415+
47,
416+
48
417+
],
418+
"loc": {
419+
"start": {
420+
"line": 2,
421+
"column": 36
422+
},
423+
"end": {
424+
"line": 3,
425+
"column": 0
426+
}
427+
},
428+
"value": "\n"
429+
},
430+
{
431+
"type": "HTMLEndTagOpen",
432+
"range": [
433+
48,
434+
58
435+
],
436+
"loc": {
437+
"start": {
438+
"line": 3,
439+
"column": 0
440+
},
441+
"end": {
442+
"line": 3,
443+
"column": 10
444+
}
445+
},
446+
"value": "template"
447+
},
448+
{
449+
"type": "HTMLTagClose",
450+
"range": [
451+
58,
452+
59
453+
],
454+
"loc": {
455+
"start": {
456+
"line": 3,
457+
"column": 10
458+
},
459+
"end": {
460+
"line": 3,
461+
"column": 11
462+
}
463+
},
464+
"value": ""
465+
},
466+
{
467+
"type": "HTMLWhitespace",
468+
"range": [
469+
59,
470+
60
471+
],
472+
"loc": {
473+
"start": {
474+
"line": 3,
475+
"column": 11
476+
},
477+
"end": {
478+
"line": 4,
479+
"column": 0
480+
}
481+
},
482+
"value": "\n"
483+
}
484+
],
485+
"comments": [],
486+
"errors": [
487+
{
488+
"message": "Unexpected token bar",
489+
"index": 31,
490+
"lineNumber": 2,
491+
"column": 20
492+
}
493+
]
494+
}
495+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<template>
2+
<textarea>{{foo bar}}</textarea>
3+
</template>
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[
2+
"<template",
3+
">",
4+
"\n ",
5+
"<textarea",
6+
">",
7+
"{{",
8+
"foo",
9+
" ",
10+
"bar",
11+
"}}",
12+
"</textarea",
13+
">",
14+
"\n",
15+
"</template",
16+
">",
17+
"\n"
18+
]
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
[
2+
{
3+
"type": "VElement",
4+
"text": "<template>\n <textarea>{{foo bar}}</textarea>\n</template>",
5+
"children": [
6+
{
7+
"type": "VStartTag",
8+
"text": "<template>",
9+
"children": []
10+
},
11+
{
12+
"type": "VText",
13+
"text": "\n ",
14+
"children": []
15+
},
16+
{
17+
"type": "VElement",
18+
"text": "<textarea>{{foo bar}}</textarea>",
19+
"children": [
20+
{
21+
"type": "VStartTag",
22+
"text": "<textarea>",
23+
"children": []
24+
},
25+
{
26+
"type": "VExpressionContainer",
27+
"text": "{{foo bar}}",
28+
"children": []
29+
},
30+
{
31+
"type": "VEndTag",
32+
"text": "</textarea>",
33+
"children": []
34+
}
35+
]
36+
},
37+
{
38+
"type": "VText",
39+
"text": "\n",
40+
"children": []
41+
},
42+
{
43+
"type": "VEndTag",
44+
"text": "</template>",
45+
"children": []
46+
}
47+
]
48+
}
49+
]

0 commit comments

Comments
 (0)
Please sign in to comment.