Skip to content

Commit

Permalink
fix(parser): Index of closing tag was misaligned (#913)
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Aug 23, 2021
1 parent d45fc82 commit 04c411c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions src/Parser.spec.ts
Expand Up @@ -89,10 +89,20 @@ describe("API", () => {
expect(p.startIndex).toBe(0);
expect(p.endIndex).toBe(2);

p.write("<bar>");
p.write("<select>");

expect(p.startIndex).toBe(3);
expect(p.endIndex).toBe(7);
expect(p.endIndex).toBe(10);

p.write("<select>");

expect(p.startIndex).toBe(11);
expect(p.endIndex).toBe(18);

p.parseChunk("</select>");

expect(p.startIndex).toBe(19);
expect(p.endIndex).toBe(27);
});

test("should not have the start index be greater than the end index", () => {
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.ts
Expand Up @@ -286,7 +286,7 @@ export class Parser {
}

onclosetag(name: string): void {
this.updatePosition(1);
this.updatePosition(2);
if (this.lowerCaseTagNames) {
name = name.toLowerCase();
}
Expand Down

0 comments on commit 04c411c

Please sign in to comment.