Commit a40e28e2 authored by David Sveningsson's avatar David Sveningsson
Browse files

fix(lexer): handle doctype with mixed case

parent 7b6ba7a1
......@@ -181,6 +181,16 @@ describe("lexer", () => {
expect(token.next().done).toBeTruthy();
});
it("mixed case doctype", () => {
expect.assertions(5);
const token = lexer.tokenize(inlineSource("<!dOcTypE html>"));
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("whitespace before doctype", () => {
expect.assertions(6);
const token = lexer.tokenize(inlineSource(" <!doctype html>"));
......
......@@ -7,7 +7,7 @@ export type TokenStream = IterableIterator<Token>;
/* eslint-disable no-useless-escape */
const MATCH_WHITESPACE = /^(?:\r\n|\r|\n|[ \t]+(?:\r\n|\r|\n)?)/;
const MATCH_DOCTYPE_OPEN = /^<!(?:DOCTYPE|doctype)\s/;
const MATCH_DOCTYPE_OPEN = /^<!(DOCTYPE)\s/i;
const MATCH_DOCTYPE_VALUE = /^[^>]+/;
const MATCH_DOCTYPE_CLOSE = /^>/;
const MATCH_XML_TAG = /^<\?xml.*?\?>\n/;
......
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