Skip to content

Commit 04d6f1c

Browse files
committed
Fix: bugs about duplicate-attributes
1 parent 833af75 commit 04d6f1c

File tree

5 files changed

+705
-0
lines changed

5 files changed

+705
-0
lines changed

src/html/intermediate-tokenizer.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export class IntermediateTokenizer {
6868
private tokenizer: Tokenizer
6969
private currentToken: IntermediateToken | null
7070
private attribute: VAttribute | null
71+
private attributeNames: Set<string>
7172
private expressionStartToken: Token | null
7273
private expressionTokens: Token[]
7374

@@ -126,6 +127,7 @@ export class IntermediateTokenizer {
126127
this.tokenizer = tokenizer
127128
this.currentToken = null
128129
this.attribute = null
130+
this.attributeNames = new Set<string>()
129131
this.expressionStartToken = null
130132
this.expressionTokens = []
131133
this.tokens = []
@@ -339,6 +341,10 @@ export class IntermediateTokenizer {
339341
this.reportParseError(token, "end-tag-with-attributes")
340342
return null
341343
}
344+
if (this.attributeNames.has(token.value)) {
345+
this.reportParseError(token, "duplicate-attribute")
346+
}
347+
this.attributeNames.add(token.value)
342348

343349
this.attribute = {
344350
type: "VAttribute",
@@ -470,6 +476,8 @@ export class IntermediateTokenizer {
470476
selfClosing: false,
471477
attributes: [],
472478
}
479+
this.attribute = null
480+
this.attributeNames.clear()
473481

474482
return result
475483
}

0 commit comments

Comments
 (0)