Skip to content

Commit e0e0253

Browse files
committedFeb 25, 2024·
fix(parser): should not treat uppercase components as special tags
close #10395
1 parent 9a365fe commit e0e0253

File tree

2 files changed

+21
-10
lines changed

2 files changed

+21
-10
lines changed
 

‎packages/compiler-core/src/tokenizer.ts

+6-9
Original file line numberDiff line numberDiff line change
@@ -553,12 +553,11 @@ export default class Tokenizer {
553553
// HTML mode
554554
// - <script>, <style> RAWTEXT
555555
// - <title>, <textarea> RCDATA
556-
const lower = c | 0x20
557-
if (lower === 116 /* t */) {
556+
if (c === 116 /* t */) {
558557
this.state = State.BeforeSpecialT
559558
} else {
560559
this.state =
561-
lower === 115 /* s */ ? State.BeforeSpecialS : State.InTagName
560+
c === 115 /* s */ ? State.BeforeSpecialS : State.InTagName
562561
}
563562
} else {
564563
this.state = State.InTagName
@@ -862,21 +861,19 @@ export default class Tokenizer {
862861
}
863862
}
864863
private stateBeforeSpecialS(c: number): void {
865-
const lower = c | 0x20
866-
if (lower === Sequences.ScriptEnd[3]) {
864+
if (c === Sequences.ScriptEnd[3]) {
867865
this.startSpecial(Sequences.ScriptEnd, 4)
868-
} else if (lower === Sequences.StyleEnd[3]) {
866+
} else if (c === Sequences.StyleEnd[3]) {
869867
this.startSpecial(Sequences.StyleEnd, 4)
870868
} else {
871869
this.state = State.InTagName
872870
this.stateInTagName(c) // Consume the token again
873871
}
874872
}
875873
private stateBeforeSpecialT(c: number): void {
876-
const lower = c | 0x20
877-
if (lower === Sequences.TitleEnd[3]) {
874+
if (c === Sequences.TitleEnd[3]) {
878875
this.startSpecial(Sequences.TitleEnd, 4)
879-
} else if (lower === Sequences.TextareaEnd[3]) {
876+
} else if (c === Sequences.TextareaEnd[3]) {
880877
this.startSpecial(Sequences.TextareaEnd, 4)
881878
} else {
882879
this.state = State.InTagName

‎packages/compiler-dom/__tests__/parse.spec.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ describe('DOM parser', () => {
2020
)
2121
const element = ast.children[0] as ElementNode
2222
const text = element.children[0] as TextNode
23-
23+
expect(element.children.length).toBe(1)
2424
expect(text).toStrictEqual({
2525
type: NodeTypes.TEXT,
2626
content: 'some<div>text</div>and<!--comment-->',
@@ -32,6 +32,20 @@ describe('DOM parser', () => {
3232
})
3333
})
3434

35+
test('should not treat Uppercase component as special tag', () => {
36+
const ast = parse(
37+
'<TextArea>some<div>text</div>and<!--comment--></TextArea>',
38+
parserOptions,
39+
)
40+
const element = ast.children[0] as ElementNode
41+
expect(element.children.map(n => n.type)).toMatchObject([
42+
NodeTypes.TEXT,
43+
NodeTypes.ELEMENT,
44+
NodeTypes.TEXT,
45+
NodeTypes.COMMENT,
46+
])
47+
})
48+
3549
test('textarea handles entities', () => {
3650
const ast = parse('<textarea>&amp;</textarea>', parserOptions)
3751
const element = ast.children[0] as ElementNode

0 commit comments

Comments
 (0)
Please sign in to comment.