Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Tokenizer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,21 @@ describe("Tokenizer", () => {
expect(tokenize("</>")).toMatchSnapshot();
});

it.each(["a</b ", "a<b /"])(
"should not emit text for an unfinished tag at EOF for %s",
(input) => {
for (let split = 0; split <= input.length; split++) {
expect(
tokenize((tokenizer) => {
tokenizer.write(input.slice(0, split));
tokenizer.write(input.slice(split));
tokenizer.end();
}).filter(([event]) => event === "ontext"),
).toEqual([["ontext", 0, 1]]);
}
},
);

it("should treat <!DOCTYPEhtml> as a declaration", () => {
expect(tokenize("<!DOCTYPEhtml>")).toMatchSnapshot();
});
Expand Down
4 changes: 3 additions & 1 deletion src/Tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,9 @@ export default class Tokenizer {
case State.InAttributeValueSq:
case State.InAttributeValueDq:
case State.InAttributeValueNq:
case State.InClosingTagName: {
case State.InSelfClosingTag:
case State.InClosingTagName:
case State.AfterClosingTagName: {
/*
* If we are currently in an opening or closing tag, us not calling the
* respective callback signals that the tag should be ignored.
Expand Down
Loading