Skip to content

Commit

Permalink
fix(parser): Strip leading whitespace encapsulated in comments
Browse files Browse the repository at this point in the history
  • Loading branch information
fb55 committed Dec 25, 2021
1 parent d91aff4 commit a812a1c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/parse.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ describe("Parse", () => {

it("should ignore comments", () => {
expect(parse("/* comment1 */ /**/ foo /*comment2*/")).toEqual([
[
{ type: "descendant" },
{ name: "foo", namespace: null, type: "tag" },
],
[{ name: "foo", namespace: null, type: "tag" }],
]);

expect(() => parse("/*/")).toThrowError("Comment was not terminated");
Expand Down
6 changes: 6 additions & 0 deletions src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,12 @@ function parseSelector(
}

selectorIndex = endIndex + 2;

// Remove leading whitespace
if (tokens.length === 0) {
stripWhitespace(0);
}

break;
}

Expand Down

0 comments on commit a812a1c

Please sign in to comment.