diff --git a/src/Tokenizer.spec.ts b/src/Tokenizer.spec.ts index 04d3735b8..90b36faf2 100644 --- a/src/Tokenizer.spec.ts +++ b/src/Tokenizer.spec.ts @@ -37,6 +37,9 @@ describe("Tokenizer", () => { it("for self-closing textarea tag", () => { expect(tokenize("
"), ).toMatchSnapshot(); }); + it("for normal xmp tag", () => { + expect(tokenize("
")).toMatchSnapshot(); + }); }); describe("should treat html inside special tags as text", () => { @@ -71,6 +77,9 @@ describe("Tokenizer", () => { tokenize(""), ).toMatchSnapshot(); }); + it("for div inside xmp tag", () => { + expect(tokenize("<div></div>")).toMatchSnapshot(); + }); }); describe("should correctly mark attributes", () => { diff --git a/src/Tokenizer.ts b/src/Tokenizer.ts index 4cf4dbe4f..453a4fefd 100644 --- a/src/Tokenizer.ts +++ b/src/Tokenizer.ts @@ -138,6 +138,7 @@ const Sequences = { TextareaEnd: new Uint8Array([ 0x3c, 0x2f, 0x74, 0x65, 0x78, 0x74, 0x61, 0x72, 0x65, 0x61, ]), // ` should support self-closing special tags > for self-closing ] `; +exports[`Tokenizer > should support self-closing special tags > for self-closing xmp tag 1`] = ` +[ + [ + "onopentagname", + 1, + 4, + ], + [ + "onselfclosingtag", + 6, + ], + [ + "onopentagname", + 8, + 11, + ], + [ + "onopentagend", + 11, + ], + [ + "onclosetag", + 14, + 17, + ], + [ + "onend", + ], +] +`; + exports[`Tokenizer > should support standard special tags > for normal script tag 1`] = ` [ [ @@ -631,6 +662,42 @@ exports[`Tokenizer > should support standard special tags > for normal textarea ] `; +exports[`Tokenizer > should support standard special tags > for normal xmp tag 1`] = ` +[ + [ + "onopentagname", + 1, + 4, + ], + [ + "onopentagend", + 4, + ], + [ + "onclosetag", + 7, + 10, + ], + [ + "onopentagname", + 12, + 15, + ], + [ + "onopentagend", + 15, + ], + [ + "onclosetag", + 18, + 21, + ], + [ + "onend", + ], +] +`; + exports[`Tokenizer > should treat html inside special tags as text > for div inside script tag 1`] = ` [ [ @@ -738,3 +805,30 @@ exports[`Tokenizer > should treat html inside special tags as text > for div ins ], ] `; + +exports[`Tokenizer > should treat html inside special tags as text > for div inside xmp tag 1`] = ` +[ + [ + "onopentagname", + 1, + 4, + ], + [ + "onopentagend", + 4, + ], + [ + "ontext", + 5, + 16, + ], + [ + "onclosetag", + 18, + 21, + ], + [ + "onend", + ], +] +`;