Commit 6c1b8308 authored by David Sveningsson's avatar David Sveningsson
Browse files

fix(lexer): handle html comment before doctype

parent c6028fa9
......@@ -213,6 +213,18 @@ describe("lexer", () => {
expect(token.next().done).toBeTruthy();
});
it("comment before doctype", () => {
expect.assertions(7);
const token = lexer.tokenize(inlineSource("<!-- foo -->\n<!doctype html>"));
expect(token.next()).toBeToken({ type: TokenType.COMMENT });
expect(token.next()).toBeToken({ type: TokenType.WHITESPACE });
expect(token.next()).toBeToken({ type: TokenType.DOCTYPE_OPEN });
expect(token.next()).toBeToken({ type: TokenType.DOCTYPE_VALUE });
expect(token.next()).toBeToken({ type: TokenType.DOCTYPE_CLOSE });
expect(token.next()).toBeToken({ type: TokenType.EOF });
expect(token.next().done).toBeTruthy();
});
it("open/void tags", () => {
expect.assertions(4);
const token = lexer.tokenize(inlineSource("<foo>"));
......
......@@ -178,6 +178,8 @@ export class Lexer {
[MATCH_XML_TAG, State.INITIAL, false],
[MATCH_DOCTYPE_OPEN, State.DOCTYPE, TokenType.DOCTYPE_OPEN],
[MATCH_WHITESPACE, State.INITIAL, TokenType.WHITESPACE],
[MATCH_DIRECTIVE, State.INITIAL, TokenType.DIRECTIVE],
[MATCH_COMMENT, State.INITIAL, TokenType.COMMENT],
[false, State.TEXT, false],
],
"expected doctype"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment