Skip to content

Commit ba08d19

Browse files
committed
Fix wrong tokenize for lone ampersand
1 parent 806a38c commit ba08d19

File tree

5 files changed

+2009
-4
lines changed

5 files changed

+2009
-4
lines changed

src/html/tokenizer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1610,14 +1610,14 @@ export class Tokenizer {
16101610
this.crStartOffset = this.offset - 1
16111611
this.buffer = [AMPERSAND]
16121612

1613-
if (isWhitespace(cp) || cp === LESS_THAN_SIGN || cp === EOF) {
1614-
return this.reconsumeAs("CHARACTER_REFERENCE_END")
1613+
if (isDigit(cp) || isLetter(cp)) {
1614+
return this.reconsumeAs("NAMED_CHARACTER_REFERENCE")
16151615
}
16161616
if (cp === NUMBER_SIGN) {
16171617
this.buffer.push(cp)
16181618
return "NUMERIC_CHARACTER_REFERENCE"
16191619
}
1620-
return this.reconsumeAs("NAMED_CHARACTER_REFERENCE")
1620+
return this.reconsumeAs("CHARACTER_REFERENCE_END")
16211621
}
16221622

16231623
/**
@@ -1818,7 +1818,7 @@ export class Tokenizer {
18181818
}
18191819

18201820
/**
1821-
* https://html.spec.whatwg.org/multipage/parsing.html#character-reference-end-state
1821+
* https://html.spec.whatwg.org/multipage/parsing.html#flush-code-points-consumed-as-a-character-reference
18221822
* @param cp The current code point.
18231823
* @returns The next state.
18241824
*/

0 commit comments

Comments
 (0)