From f91700405bec90118908f51cf81322167e6b9941 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Sat, 28 Aug 2021 00:18:42 +0100 Subject: [PATCH] feat(parser): Add `isImplied` flag to `onopentag`/`onclosetag` (#930) --- src/Parser.spec.ts | 2 +- src/Parser.ts | 61 +++-- src/__fixtures__/Events/01-simple.json | 5 +- src/__fixtures__/Events/02-template.json | 9 +- .../Events/03-lowercase_tags.json | 5 +- src/__fixtures__/Events/04-cdata.json | 4 +- src/__fixtures__/Events/05-cdata-special.json | 4 +- src/__fixtures__/Events/07-self-closing.json | 9 +- .../Events/08-implicit-close-tags.json | 91 +++---- src/__fixtures__/Events/09-attributes.json | 5 +- src/__fixtures__/Events/10-crazy-attrib.json | 5 +- .../Events/11-script_in_script.json | 8 +- .../Events/12-long-comment-end.json | 10 +- .../Events/13-long-cdata-end.json | 12 +- .../Events/14-implicit-open-tags.json | 20 +- .../Events/16-double_attribs.json | 5 +- .../Events/21-entity_in_attribute.json | 5 +- .../Events/22-double_brackets.json | 4 +- .../Events/24-special_special.json | 44 ++-- .../Events/26-not-quite-closed.json | 5 +- .../Events/27-entities_in_attributes.json | 5 +- .../32-script-ending-with-lessthan.json | 4 +- .../Events/35-non-br-void-close-tag.json | 8 +- .../Events/36-entity-in-attrib.json | 5 +- .../Events/37-entity-in-title.json | 4 +- .../Events/38-entity-in-title-no-decode.json | 4 +- .../Events/39-title-in-script.json | 4 +- src/__fixtures__/Events/40-xml_tags.json | 8 +- src/__fixtures__/Events/44-indices.json | 17 +- src/__snapshots__/WritableStream.spec.ts.snap | 234 ++++++++++++++++++ 30 files changed, 434 insertions(+), 172 deletions(-) diff --git a/src/Parser.spec.ts b/src/Parser.spec.ts index c8ac3d643..e546c5da7 100644 --- a/src/Parser.spec.ts +++ b/src/Parser.spec.ts @@ -143,7 +143,7 @@ describe("API", () => { const p = new Parser(null); // Should not throw - p.write("<__proto__>"); + p.parseChunk("<__proto__>"); }); test("should support custom tokenizer", () => { diff --git a/src/Parser.ts b/src/Parser.ts index f628fb3bd..bac5f1a43 100644 --- a/src/Parser.ts +++ b/src/Parser.ts @@ -167,7 +167,7 @@ export interface Handler { */ onend(): void; onerror(error: Error): void; - onclosetag(name: string): void; + onclosetag(name: string, isImplied: boolean): void; onopentagname(name: string): void; /** * @@ -180,7 +180,11 @@ export interface Handler { value: string, quote?: string | undefined | null ): void; - onopentag(name: string, attribs: { [s: string]: string }): void; + onopentag( + name: string, + attribs: { [s: string]: string }, + isImplied: boolean + ): void; ontext(data: string): void; oncomment(data: string): void; oncdatastart(): void; @@ -266,7 +270,7 @@ export class Parser { impliesClose.has(this.stack[this.stack.length - 1]) ) { const el = this.stack.pop()!; - this.cbs.onclosetag?.(el); + this.cbs.onclosetag?.(el, true); } } if (!this.isVoidElement(name)) { @@ -281,20 +285,25 @@ export class Parser { if (this.cbs.onopentag) this.attribs = {}; } - /** @internal */ - onopentagend(): void { + private endOpenTag(isImplied: boolean) { this.startIndex = this.openTagStart; this.endIndex = this.tokenizer.getAbsoluteIndex(); if (this.attribs) { - this.cbs.onopentag?.(this.tagname, this.attribs); + this.cbs.onopentag?.(this.tagname, this.attribs, isImplied); this.attribs = null; } if (this.cbs.onclosetag && this.isVoidElement(this.tagname)) { - this.cbs.onclosetag(this.tagname); + this.cbs.onclosetag(this.tagname, true); } this.tagname = ""; + } + + /** @internal */ + onopentagend(): void { + this.endOpenTag(false); + // Set `startIndex` for next node this.startIndex = this.endIndex + 1; } @@ -306,29 +315,33 @@ export class Parser { if (this.lowerCaseTagNames) { name = name.toLowerCase(); } + if ( foreignContextElements.has(name) || htmlIntegrationElements.has(name) ) { this.foreignContext.pop(); } - if (this.stack.length && !this.isVoidElement(name)) { - let pos = this.stack.lastIndexOf(name); + + if (!this.isVoidElement(name)) { + const pos = this.stack.lastIndexOf(name); if (pos !== -1) { if (this.cbs.onclosetag) { - pos = this.stack.length - pos; - while (pos--) { + let count = this.stack.length - pos; + while (count--) { // We know the stack has sufficient elements. - this.cbs.onclosetag(this.stack.pop() as string); + this.cbs.onclosetag(this.stack.pop()!, pos !== 0); } } else this.stack.length = pos; - } else if (name === "p" && !this.options.xmlMode) { + } else if (!this.options.xmlMode && name === "p") { this.emitOpenTag(name); - this.closeCurrentTag(); + this.closeCurrentTag(true); } - } else if (!this.options.xmlMode && (name === "br" || name === "p")) { - this.emitOpenTag(name); - this.closeCurrentTag(); + } else if (!this.options.xmlMode && name === "br") { + // We can't go through `emitOpenTag` here, as `br` would be implicitly closed. + this.cbs.onopentagname?.(name); + this.cbs.onopentag?.(name, {}, true); + this.cbs.onclosetag?.(name, false); } // Set `startIndex` for next node @@ -342,23 +355,21 @@ export class Parser { this.options.recognizeSelfClosing || this.foreignContext[this.foreignContext.length - 1] ) { - this.closeCurrentTag(); + this.closeCurrentTag(false); } else { // Ignore the fact that the tag is self-closing. this.onopentagend(); } } - private closeCurrentTag() { + private closeCurrentTag(isOpenImplied: boolean) { const name = this.tagname; - this.onopentagend(); + this.endOpenTag(isOpenImplied); // Self-closing tags will be on the top of the stack if (this.stack[this.stack.length - 1] === name) { - // Reset the start index - this.startIndex = this.openTagStart; - - this.cbs.onclosetag?.(name); + // If the opening tag isn't implied, the closing tag has to be implied. + this.cbs.onclosetag?.(name, !isOpenImplied); this.stack.pop(); } } @@ -471,7 +482,7 @@ export class Parser { for ( let i = this.stack.length; i > 0; - this.cbs.onclosetag(this.stack[--i]) + this.cbs.onclosetag(this.stack[--i], true) ); } this.cbs.onend?.(); diff --git a/src/__fixtures__/Events/01-simple.json b/src/__fixtures__/Events/01-simple.json index aad23069b..86de0b8c0 100644 --- a/src/__fixtures__/Events/01-simple.json +++ b/src/__fixtures__/Events/01-simple.json @@ -22,7 +22,8 @@ "h1", { "class": "test" - } + }, + false ] }, { @@ -35,7 +36,7 @@ "event": "closetag", "startIndex": 19, "endIndex": 23, - "data": ["h1"] + "data": ["h1", false] } ] } diff --git a/src/__fixtures__/Events/02-template.json b/src/__fixtures__/Events/02-template.json index 57dc96e03..c72e872cc 100644 --- a/src/__fixtures__/Events/02-template.json +++ b/src/__fixtures__/Events/02-template.json @@ -12,7 +12,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 2, - "data": ["p", {}] + "data": ["p", {}, false] }, { "event": "opentagname", @@ -34,7 +34,8 @@ "script", { "type": "text/template" - } + }, + false ] }, { @@ -47,13 +48,13 @@ "event": "closetag", "startIndex": 49, "endIndex": 57, - "data": ["script"] + "data": ["script", true] }, { "event": "closetag", "startIndex": 58, "endIndex": 61, - "data": ["p"] + "data": ["p", false] } ] } diff --git a/src/__fixtures__/Events/03-lowercase_tags.json b/src/__fixtures__/Events/03-lowercase_tags.json index fb86e89d7..1f45a8f20 100644 --- a/src/__fixtures__/Events/03-lowercase_tags.json +++ b/src/__fixtures__/Events/03-lowercase_tags.json @@ -27,7 +27,8 @@ "h1", { "class": "test" - } + }, + false ] }, { @@ -40,7 +41,7 @@ "event": "closetag", "startIndex": 19, "endIndex": 23, - "data": ["h1"] + "data": ["h1", false] } ] } diff --git a/src/__fixtures__/Events/04-cdata.json b/src/__fixtures__/Events/04-cdata.json index 872625745..9a80038f8 100644 --- a/src/__fixtures__/Events/04-cdata.json +++ b/src/__fixtures__/Events/04-cdata.json @@ -17,7 +17,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 4, - "data": ["tag", {}] + "data": ["tag", {}, false] }, { "event": "cdatastart", @@ -41,7 +41,7 @@ "event": "closetag", "startIndex": 42, "endIndex": 47, - "data": ["tag"] + "data": ["tag", false] }, { "event": "processinginstruction", diff --git a/src/__fixtures__/Events/05-cdata-special.json b/src/__fixtures__/Events/05-cdata-special.json index 74f2b4224..75fd2c989 100644 --- a/src/__fixtures__/Events/05-cdata-special.json +++ b/src/__fixtures__/Events/05-cdata-special.json @@ -12,7 +12,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 7, - "data": ["script", {}] + "data": ["script", {}, false] }, { "event": "text", @@ -24,7 +24,7 @@ "event": "closetag", "startIndex": 53, "endIndex": 61, - "data": ["script"] + "data": ["script", false] } ] } diff --git a/src/__fixtures__/Events/07-self-closing.json b/src/__fixtures__/Events/07-self-closing.json index d6bea9444..847dbc6ad 100644 --- a/src/__fixtures__/Events/07-self-closing.json +++ b/src/__fixtures__/Events/07-self-closing.json @@ -22,7 +22,8 @@ "a", { "href": "http://test.com/" - } + }, + false ] }, { @@ -35,7 +36,7 @@ "event": "closetag", "startIndex": 28, "endIndex": 31, - "data": ["a"] + "data": ["a", false] }, { "event": "opentagname", @@ -47,13 +48,13 @@ "event": "opentag", "startIndex": 32, "endIndex": 38, - "data": ["hr", {}] + "data": ["hr", {}, false] }, { "event": "closetag", "startIndex": 32, "endIndex": 38, - "data": ["hr"] + "data": ["hr", true] } ] } diff --git a/src/__fixtures__/Events/08-implicit-close-tags.json b/src/__fixtures__/Events/08-implicit-close-tags.json index 37e06f020..7efb397a6 100644 --- a/src/__fixtures__/Events/08-implicit-close-tags.json +++ b/src/__fixtures__/Events/08-implicit-close-tags.json @@ -12,7 +12,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 3, - "data": ["ol", {}] + "data": ["ol", {}, false] }, { "event": "opentagname", @@ -34,7 +34,8 @@ "li", { "class": "test" - } + }, + false ] }, { @@ -47,7 +48,7 @@ "event": "opentag", "startIndex": 19, "endIndex": 23, - "data": ["div", {}] + "data": ["div", {}, false] }, { "event": "opentagname", @@ -69,7 +70,8 @@ "table", { "style": "width:100%" - } + }, + false ] }, { @@ -82,7 +84,7 @@ "event": "opentag", "startIndex": 48, "endIndex": 51, - "data": ["tr", {}] + "data": ["tr", {}, false] }, { "event": "opentagname", @@ -94,7 +96,7 @@ "event": "opentag", "startIndex": 52, "endIndex": 55, - "data": ["th", {}] + "data": ["th", {}, false] }, { "event": "text", @@ -106,7 +108,7 @@ "event": "closetag", "startIndex": 58, "endIndex": 61, - "data": ["th"] + "data": ["th", true] }, { "event": "opentagname", @@ -128,7 +130,8 @@ "td", { "colspan": "2" - } + }, + false ] }, { @@ -141,7 +144,7 @@ "event": "opentag", "startIndex": 72, "endIndex": 75, - "data": ["h3", {}] + "data": ["h3", {}, false] }, { "event": "text", @@ -153,19 +156,19 @@ "event": "closetag", "startIndex": 83, "endIndex": 87, - "data": ["h3"] + "data": ["h3", true] }, { "event": "closetag", "startIndex": 88, "endIndex": 91, - "data": ["td"] + "data": ["td", true] }, { "event": "closetag", "startIndex": 88, "endIndex": 91, - "data": ["tr"] + "data": ["tr", true] }, { "event": "opentagname", @@ -177,7 +180,7 @@ "event": "opentag", "startIndex": 88, "endIndex": 91, - "data": ["tr", {}] + "data": ["tr", {}, false] }, { "event": "opentagname", @@ -189,7 +192,7 @@ "event": "opentag", "startIndex": 92, "endIndex": 95, - "data": ["td", {}] + "data": ["td", {}, false] }, { "event": "opentagname", @@ -201,7 +204,7 @@ "event": "opentag", "startIndex": 96, "endIndex": 100, - "data": ["div", {}] + "data": ["div", {}, false] }, { "event": "text", @@ -213,13 +216,13 @@ "event": "closetag", "startIndex": 104, "endIndex": 109, - "data": ["div"] + "data": ["div", true] }, { "event": "closetag", "startIndex": 110, "endIndex": 113, - "data": ["td"] + "data": ["td", true] }, { "event": "opentagname", @@ -231,7 +234,7 @@ "event": "opentag", "startIndex": 110, "endIndex": 113, - "data": ["td", {}] + "data": ["td", {}, false] }, { "event": "opentagname", @@ -243,7 +246,7 @@ "event": "opentag", "startIndex": 114, "endIndex": 118, - "data": ["div", {}] + "data": ["div", {}, false] }, { "event": "text", @@ -255,37 +258,37 @@ "event": "closetag", "startIndex": 123, "endIndex": 128, - "data": ["div"] + "data": ["div", true] }, { "event": "closetag", "startIndex": 129, "endIndex": 136, - "data": ["td"] + "data": ["td", true] }, { "event": "closetag", "startIndex": 129, "endIndex": 136, - "data": ["tr"] + "data": ["tr", true] }, { "event": "closetag", "startIndex": 129, "endIndex": 136, - "data": ["table"] + "data": ["table", true] }, { "event": "closetag", "startIndex": 137, "endIndex": 142, - "data": ["div"] + "data": ["div", true] }, { "event": "closetag", "startIndex": 143, "endIndex": 146, - "data": ["li"] + "data": ["li", true] }, { "event": "opentagname", @@ -297,7 +300,7 @@ "event": "opentag", "startIndex": 143, "endIndex": 146, - "data": ["li", {}] + "data": ["li", {}, false] }, { "event": "opentagname", @@ -309,7 +312,7 @@ "event": "opentag", "startIndex": 147, "endIndex": 151, - "data": ["div", {}] + "data": ["div", {}, false] }, { "event": "opentagname", @@ -321,7 +324,7 @@ "event": "opentag", "startIndex": 152, "endIndex": 155, - "data": ["h3", {}] + "data": ["h3", {}, false] }, { "event": "text", @@ -333,25 +336,25 @@ "event": "closetag", "startIndex": 165, "endIndex": 169, - "data": ["h3"] + "data": ["h3", true] }, { "event": "closetag", "startIndex": 170, "endIndex": 175, - "data": ["div"] + "data": ["div", true] }, { "event": "closetag", "startIndex": 176, "endIndex": 180, - "data": ["li"] + "data": ["li", true] }, { "event": "closetag", "startIndex": 181, "endIndex": 185, - "data": ["ol"] + "data": ["ol", false] }, { "event": "opentagname", @@ -363,7 +366,7 @@ "event": "opentag", "startIndex": 186, "endIndex": 188, - "data": ["p", {}] + "data": ["p", {}, false] }, { "event": "text", @@ -375,7 +378,7 @@ "event": "closetag", "startIndex": 193, "endIndex": 196, - "data": ["p"] + "data": ["p", true] }, { "event": "opentagname", @@ -387,7 +390,7 @@ "event": "opentag", "startIndex": 193, "endIndex": 196, - "data": ["h4", {}] + "data": ["h4", {}, false] }, { "event": "text", @@ -399,7 +402,7 @@ "event": "closetag", "startIndex": 206, "endIndex": 210, - "data": ["h4"] + "data": ["h4", false] }, { "event": "opentagname", @@ -411,13 +414,13 @@ "event": "opentag", "startIndex": 211, "endIndex": 213, - "data": ["p", {}] + "data": ["p", {}, false] }, { "event": "closetag", "startIndex": 214, "endIndex": 217, - "data": ["p"] + "data": ["p", true] }, { "event": "opentagname", @@ -429,7 +432,7 @@ "event": "opentag", "startIndex": 214, "endIndex": 217, - "data": ["ul", {}] + "data": ["ul", {}, false] }, { "event": "opentagname", @@ -441,7 +444,7 @@ "event": "opentag", "startIndex": 218, "endIndex": 221, - "data": ["li", {}] + "data": ["li", {}, false] }, { "event": "text", @@ -453,7 +456,7 @@ "event": "closetag", "startIndex": 224, "endIndex": 227, - "data": ["li"] + "data": ["li", true] }, { "event": "opentagname", @@ -465,7 +468,7 @@ "event": "opentag", "startIndex": 224, "endIndex": 227, - "data": ["li", {}] + "data": ["li", {}, false] }, { "event": "text", @@ -477,13 +480,13 @@ "event": "closetag", "startIndex": 231, "endIndex": 235, - "data": ["li"] + "data": ["li", false] }, { "event": "closetag", "startIndex": 231, "endIndex": 235, - "data": ["ul"] + "data": ["ul", false] } ] } diff --git a/src/__fixtures__/Events/09-attributes.json b/src/__fixtures__/Events/09-attributes.json index 87bc4febe..7bcdd68aa 100644 --- a/src/__fixtures__/Events/09-attributes.json +++ b/src/__fixtures__/Events/09-attributes.json @@ -43,7 +43,8 @@ "title": "test1", "disabled": "", "value": "test2" - } + }, + false ] }, { @@ -56,7 +57,7 @@ "event": "closetag", "startIndex": 60, "endIndex": 68, - "data": ["button"] + "data": ["button", false] } ] } diff --git a/src/__fixtures__/Events/10-crazy-attrib.json b/src/__fixtures__/Events/10-crazy-attrib.json index 41e01ae72..6e758eca1 100644 --- a/src/__fixtures__/Events/10-crazy-attrib.json +++ b/src/__fixtures__/Events/10-crazy-attrib.json @@ -29,7 +29,8 @@ { "<": "", "fail": "" - } + }, + false ] }, { @@ -42,7 +43,7 @@ "event": "closetag", "startIndex": 20, "endIndex": 23, - "data": ["p"] + "data": ["p", false] } ] } diff --git a/src/__fixtures__/Events/11-script_in_script.json b/src/__fixtures__/Events/11-script_in_script.json index 4702fd661..6476de4e3 100644 --- a/src/__fixtures__/Events/11-script_in_script.json +++ b/src/__fixtures__/Events/11-script_in_script.json @@ -12,7 +12,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 2, - "data": ["p", {}] + "data": ["p", {}, false] }, { "event": "opentagname", @@ -24,7 +24,7 @@ "event": "opentag", "startIndex": 3, "endIndex": 10, - "data": ["script", {}] + "data": ["script", {}, false] }, { "event": "text", @@ -36,13 +36,13 @@ "event": "closetag", "startIndex": 44, "endIndex": 52, - "data": ["script"] + "data": ["script", true] }, { "event": "closetag", "startIndex": 53, "endIndex": 56, - "data": ["p"] + "data": ["p", false] } ] } diff --git a/src/__fixtures__/Events/12-long-comment-end.json b/src/__fixtures__/Events/12-long-comment-end.json index eff55667e..ae018810b 100644 --- a/src/__fixtures__/Events/12-long-comment-end.json +++ b/src/__fixtures__/Events/12-long-comment-end.json @@ -22,14 +22,15 @@ "meta", { "id": "before" - } + }, + false ] }, { "event": "closetag", "startIndex": 0, "endIndex": 17, - "data": ["meta"] + "data": ["meta", true] }, { "event": "comment", @@ -63,14 +64,15 @@ "meta", { "id": "after" - } + }, + false ] }, { "event": "closetag", "startIndex": 32, "endIndex": 48, - "data": ["meta"] + "data": ["meta", true] } ] } diff --git a/src/__fixtures__/Events/13-long-cdata-end.json b/src/__fixtures__/Events/13-long-cdata-end.json index 652eea3fc..e353f57e4 100644 --- a/src/__fixtures__/Events/13-long-cdata-end.json +++ b/src/__fixtures__/Events/13-long-cdata-end.json @@ -17,13 +17,13 @@ "event": "opentag", "startIndex": 0, "endIndex": 9, - "data": ["before", {}] + "data": ["before", {}, false] }, { "event": "closetag", "startIndex": 0, "endIndex": 9, - "data": ["before"] + "data": ["before", true] }, { "event": "opentagname", @@ -35,7 +35,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 14, - "data": ["tag", {}] + "data": ["tag", {}, false] }, { "event": "cdatastart", @@ -59,7 +59,7 @@ "event": "closetag", "startIndex": 34, "endIndex": 39, - "data": ["tag"] + "data": ["tag", false] }, { "event": "opentagname", @@ -71,13 +71,13 @@ "event": "opentag", "startIndex": 40, "endIndex": 48, - "data": ["after", {}] + "data": ["after", {}, false] }, { "event": "closetag", "startIndex": 40, "endIndex": 48, - "data": ["after"] + "data": ["after", true] } ] } diff --git a/src/__fixtures__/Events/14-implicit-open-tags.json b/src/__fixtures__/Events/14-implicit-open-tags.json index 10b30438b..d3817b45a 100644 --- a/src/__fixtures__/Events/14-implicit-open-tags.json +++ b/src/__fixtures__/Events/14-implicit-open-tags.json @@ -12,7 +12,7 @@ "event": "opentag", "startIndex": 0, "endIndex": 4, - "data": ["div", {}] + "data": ["div", {}, false] }, { "event": "text", @@ -30,13 +30,13 @@ "event": "opentag", "startIndex": 10, "endIndex": 13, - "data": ["p", {}] + "data": ["p", {}, true] }, { "event": "closetag", "startIndex": 10, "endIndex": 13, - "data": ["p"] + "data": ["p", false] }, { "event": "text", @@ -54,19 +54,19 @@ "event": "opentag", "startIndex": 19, "endIndex": 23, - "data": ["br", {}] + "data": ["br", {}, true] }, { "event": "closetag", "startIndex": 19, "endIndex": 23, - "data": ["br"] + "data": ["br", false] }, { "event": "closetag", "startIndex": 33, "endIndex": 38, - "data": ["div"] + "data": ["div", false] }, { "event": "opentagname", @@ -78,13 +78,13 @@ "event": "opentag", "startIndex": 39, "endIndex": 42, - "data": ["p", {}] + "data": ["p", {}, true] }, { "event": "closetag", "startIndex": 39, "endIndex": 42, - "data": ["p"] + "data": ["p", false] }, { "event": "opentagname", @@ -96,13 +96,13 @@ "event": "opentag", "startIndex": 43, "endIndex": 47, - "data": ["br", {}] + "data": ["br", {}, true] }, { "event": "closetag", "startIndex": 43, "endIndex": 47, - "data": ["br"] + "data": ["br", false] } ] } diff --git a/src/__fixtures__/Events/16-double_attribs.json b/src/__fixtures__/Events/16-double_attribs.json index c71ad9da0..e973dace8 100644 --- a/src/__fixtures__/Events/16-double_attribs.json +++ b/src/__fixtures__/Events/16-double_attribs.json @@ -28,14 +28,15 @@ "h1", { "class": "test" - } + }, + false ] }, { "event": "closetag", "startIndex": 25, "endIndex": 29, - "data": ["h1"] + "data": ["h1", false] } ] } diff --git a/src/__fixtures__/Events/21-entity_in_attribute.json b/src/__fixtures__/Events/21-entity_in_attribute.json index 21f642d98..72d1b750d 100644 --- a/src/__fixtures__/Events/21-entity_in_attribute.json +++ b/src/__fixtures__/Events/21-entity_in_attribute.json @@ -26,14 +26,15 @@ "a", { "href": "http://example.com/pa#x61ge?param=value¶m2¶m3=A link: Github Object { "data": Array [ "description", + true, ], "endIndex": 1574, "event": "closetag", @@ -2618,6 +2720,7 @@ Great test content
A link: Github "data": Array [ "dc:date", Object {}, + false, ], "endIndex": 1586, "event": "opentag", @@ -2634,6 +2737,7 @@ Great test content
A link: Github Object { "data": Array [ "dc:date", + true, ], "endIndex": 1621, "event": "closetag", @@ -2660,6 +2764,7 @@ Great test content
A link: Github "data": Array [ "dc:language", Object {}, + false, ], "endIndex": 1637, "event": "opentag", @@ -2676,6 +2781,7 @@ Great test content
A link: Github Object { "data": Array [ "dc:language", + true, ], "endIndex": 1656, "event": "closetag", @@ -2702,6 +2808,7 @@ Great test content
A link: Github "data": Array [ "dc:rights", Object {}, + false, ], "endIndex": 1670, "event": "opentag", @@ -2718,6 +2825,7 @@ Great test content
A link: Github Object { "data": Array [ "dc:rights", + true, ], "endIndex": 1708, "event": "closetag", @@ -2744,6 +2852,7 @@ Great test content
A link: Github "data": Array [ "dc:source", Object {}, + false, ], "endIndex": 1722, "event": "opentag", @@ -2762,6 +2871,7 @@ http://somefakesite/path/to/something.html Object { "data": Array [ "dc:source", + true, ], "endIndex": 1778, "event": "closetag", @@ -2788,6 +2898,7 @@ http://somefakesite/path/to/something.html "data": Array [ "dc:title", Object {}, + false, ], "endIndex": 1791, "event": "opentag", @@ -2816,6 +2927,7 @@ http://somefakesite/path/to/something.html Object { "data": Array [ "dc:title", + true, ], "endIndex": 1833, "event": "closetag", @@ -2842,6 +2954,7 @@ http://somefakesite/path/to/something.html "data": Array [ "dc:type", Object {}, + false, ], "endIndex": 1845, "event": "opentag", @@ -2858,6 +2971,7 @@ http://somefakesite/path/to/something.html Object { "data": Array [ "dc:type", + true, ], "endIndex": 1859, "event": "closetag", @@ -2884,6 +2998,7 @@ http://somefakesite/path/to/something.html "data": Array [ "dcterms:issued", Object {}, + false, ], "endIndex": 1878, "event": "opentag", @@ -2900,6 +3015,7 @@ http://somefakesite/path/to/something.html Object { "data": Array [ "dcterms:issued", + true, ], "endIndex": 1920, "event": "closetag", @@ -2917,6 +3033,7 @@ http://somefakesite/path/to/something.html Object { "data": Array [ "item", + true, ], "endIndex": 1929, "event": "closetag", @@ -2955,6 +3072,7 @@ http://somefakesite/path/to/something.html Object { "rdf:about": "http://somefakesite/path/to/something-else.html", }, + false, ], "endIndex": 1997, "event": "opentag", @@ -2981,6 +3099,7 @@ http://somefakesite/path/to/something.html "data": Array [ "title", Object {}, + false, ], "endIndex": 2007, "event": "opentag", @@ -3011,6 +3130,7 @@ This space intentionally left blank Object { "data": Array [ "title", + true, ], "endIndex": 2064, "event": "closetag", @@ -3037,6 +3157,7 @@ This space intentionally left blank "data": Array [ "link", Object {}, + false, ], "endIndex": 2073, "event": "opentag", @@ -3055,6 +3176,7 @@ http://somefakesite/path/to/something-else.html Object { "data": Array [ "link", + true, ], "endIndex": 2129, "event": "closetag", @@ -3081,6 +3203,7 @@ http://somefakesite/path/to/something-else.html "data": Array [ "description", Object {}, + false, ], "endIndex": 2145, "event": "opentag", @@ -3111,6 +3234,7 @@ The early bird gets the worm Object { "data": Array [ "description", + true, ], "endIndex": 2201, "event": "closetag", @@ -3137,6 +3261,7 @@ The early bird gets the worm "data": Array [ "dc:date", Object {}, + false, ], "endIndex": 2213, "event": "opentag", @@ -3153,6 +3278,7 @@ The early bird gets the worm Object { "data": Array [ "dc:date", + true, ], "endIndex": 2248, "event": "closetag", @@ -3179,6 +3305,7 @@ The early bird gets the worm "data": Array [ "dc:language", Object {}, + false, ], "endIndex": 2264, "event": "opentag", @@ -3195,6 +3322,7 @@ The early bird gets the worm Object { "data": Array [ "dc:language", + true, ], "endIndex": 2283, "event": "closetag", @@ -3221,6 +3349,7 @@ The early bird gets the worm "data": Array [ "dc:rights", Object {}, + false, ], "endIndex": 2297, "event": "opentag", @@ -3237,6 +3366,7 @@ The early bird gets the worm Object { "data": Array [ "dc:rights", + true, ], "endIndex": 2335, "event": "closetag", @@ -3263,6 +3393,7 @@ The early bird gets the worm "data": Array [ "dc:source", Object {}, + false, ], "endIndex": 2349, "event": "opentag", @@ -3281,6 +3412,7 @@ http://somefakesite/path/to/something-else.html Object { "data": Array [ "dc:source", + true, ], "endIndex": 2410, "event": "closetag", @@ -3307,6 +3439,7 @@ http://somefakesite/path/to/something-else.html "data": Array [ "dc:title", Object {}, + false, ], "endIndex": 2423, "event": "opentag", @@ -3337,6 +3470,7 @@ This space intentionally left blank Object { "data": Array [ "dc:title", + true, ], "endIndex": 2483, "event": "closetag", @@ -3363,6 +3497,7 @@ This space intentionally left blank "data": Array [ "dc:type", Object {}, + false, ], "endIndex": 2495, "event": "opentag", @@ -3379,6 +3514,7 @@ This space intentionally left blank Object { "data": Array [ "dc:type", + true, ], "endIndex": 2509, "event": "closetag", @@ -3405,6 +3541,7 @@ This space intentionally left blank "data": Array [ "dcterms:issued", Object {}, + false, ], "endIndex": 2528, "event": "opentag", @@ -3421,6 +3558,7 @@ This space intentionally left blank Object { "data": Array [ "dcterms:issued", + true, ], "endIndex": 2570, "event": "closetag", @@ -3438,6 +3576,7 @@ This space intentionally left blank Object { "data": Array [ "item", + true, ], "endIndex": 2579, "event": "closetag", @@ -3455,6 +3594,7 @@ This space intentionally left blank Object { "data": Array [ "rdf:RDF", + false, ], "endIndex": 2590, "event": "closetag", @@ -3530,6 +3670,7 @@ Array [ Object { "version": "2.0", }, + false, ], "endIndex": 106, "event": "opentag", @@ -3556,6 +3697,7 @@ Array [ "data": Array [ "channel", Object {}, + false, ], "endIndex": 119, "event": "opentag", @@ -3582,6 +3724,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 133, "event": "opentag", @@ -3598,6 +3741,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 153, "event": "closetag", @@ -3624,6 +3768,7 @@ Array [ "data": Array [ "link", Object {}, + false, ], "endIndex": 166, "event": "opentag", @@ -3640,6 +3785,7 @@ Array [ Object { "data": Array [ "link", + true, ], "endIndex": 202, "event": "closetag", @@ -3666,6 +3812,7 @@ Array [ "data": Array [ "description", Object {}, + false, ], "endIndex": 222, "event": "opentag", @@ -3682,6 +3829,7 @@ Array [ Object { "data": Array [ "description", + true, ], "endIndex": 265, "event": "closetag", @@ -3708,6 +3856,7 @@ Array [ "data": Array [ "language", Object {}, + false, ], "endIndex": 282, "event": "opentag", @@ -3724,6 +3873,7 @@ Array [ Object { "data": Array [ "language", + true, ], "endIndex": 298, "event": "closetag", @@ -3750,6 +3900,7 @@ Array [ "data": Array [ "pubDate", Object {}, + false, ], "endIndex": 314, "event": "opentag", @@ -3766,6 +3917,7 @@ Array [ Object { "data": Array [ "pubDate", + true, ], "endIndex": 353, "event": "closetag", @@ -3793,6 +3945,7 @@ Array [ "data": Array [ "lastBuildDate", Object {}, + false, ], "endIndex": 376, "event": "opentag", @@ -3809,6 +3962,7 @@ Array [ Object { "data": Array [ "lastBuildDate", + true, ], "endIndex": 421, "event": "closetag", @@ -3835,6 +3989,7 @@ Array [ "data": Array [ "docs", Object {}, + false, ], "endIndex": 434, "event": "opentag", @@ -3851,6 +4006,7 @@ Array [ Object { "data": Array [ "docs", + true, ], "endIndex": 478, "event": "closetag", @@ -3877,6 +4033,7 @@ Array [ "data": Array [ "generator", Object {}, + false, ], "endIndex": 496, "event": "opentag", @@ -3893,6 +4050,7 @@ Array [ Object { "data": Array [ "generator", + true, ], "endIndex": 525, "event": "closetag", @@ -3919,6 +4077,7 @@ Array [ "data": Array [ "managingEditor", Object {}, + false, ], "endIndex": 548, "event": "opentag", @@ -3935,6 +4094,7 @@ Array [ Object { "data": Array [ "managingEditor", + true, ], "endIndex": 583, "event": "closetag", @@ -3961,6 +4121,7 @@ Array [ "data": Array [ "webMaster", Object {}, + false, ], "endIndex": 601, "event": "opentag", @@ -3977,6 +4138,7 @@ Array [ Object { "data": Array [ "webMaster", + true, ], "endIndex": 634, "event": "closetag", @@ -4003,6 +4165,7 @@ Array [ "data": Array [ "item", Object {}, + false, ], "endIndex": 647, "event": "opentag", @@ -4030,6 +4193,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 665, "event": "opentag", @@ -4046,6 +4210,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 682, "event": "closetag", @@ -4072,6 +4237,7 @@ Array [ "data": Array [ "link", Object {}, + false, ], "endIndex": 698, "event": "opentag", @@ -4088,6 +4254,7 @@ Array [ Object { "data": Array [ "link", + true, ], "endIndex": 761, "event": "closetag", @@ -4114,6 +4281,7 @@ Array [ "data": Array [ "description", Object {}, + false, ], "endIndex": 784, "event": "opentag", @@ -4130,6 +4298,7 @@ Array [ Object { "data": Array [ "description", + true, ], "endIndex": 1034, "event": "closetag", @@ -4156,6 +4325,7 @@ Array [ "data": Array [ "pubDate", Object {}, + false, ], "endIndex": 1053, "event": "opentag", @@ -4172,6 +4342,7 @@ Array [ Object { "data": Array [ "pubDate", + true, ], "endIndex": 1092, "event": "closetag", @@ -4198,6 +4369,7 @@ Array [ "data": Array [ "guid", Object {}, + false, ], "endIndex": 1108, "event": "opentag", @@ -4214,6 +4386,7 @@ Array [ Object { "data": Array [ "guid", + true, ], "endIndex": 1167, "event": "closetag", @@ -4232,6 +4405,7 @@ Array [ Object { "data": Array [ "item", + true, ], "endIndex": 1182, "event": "closetag", @@ -4258,6 +4432,7 @@ Array [ "data": Array [ "item", Object {}, + false, ], "endIndex": 1195, "event": "opentag", @@ -4284,6 +4459,7 @@ Array [ "data": Array [ "description", Object {}, + false, ], "endIndex": 1218, "event": "opentag", @@ -4300,6 +4476,7 @@ Array [ Object { "data": Array [ "description", + true, ], "endIndex": 1449, "event": "closetag", @@ -4326,6 +4503,7 @@ Array [ "data": Array [ "pubDate", Object {}, + false, ], "endIndex": 1468, "event": "opentag", @@ -4342,6 +4520,7 @@ Array [ Object { "data": Array [ "pubDate", + true, ], "endIndex": 1507, "event": "closetag", @@ -4368,6 +4547,7 @@ Array [ "data": Array [ "guid", Object {}, + false, ], "endIndex": 1523, "event": "opentag", @@ -4384,6 +4564,7 @@ Array [ Object { "data": Array [ "guid", + true, ], "endIndex": 1582, "event": "closetag", @@ -4402,6 +4583,7 @@ Array [ Object { "data": Array [ "item", + true, ], "endIndex": 1597, "event": "closetag", @@ -4428,6 +4610,7 @@ Array [ "data": Array [ "item", Object {}, + false, ], "endIndex": 1610, "event": "opentag", @@ -4454,6 +4637,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 1627, "event": "opentag", @@ -4470,6 +4654,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 1660, "event": "closetag", @@ -4496,6 +4681,7 @@ Array [ "data": Array [ "link", Object {}, + false, ], "endIndex": 1676, "event": "opentag", @@ -4512,6 +4698,7 @@ Array [ Object { "data": Array [ "link", + true, ], "endIndex": 1737, "event": "closetag", @@ -4538,6 +4725,7 @@ Array [ "data": Array [ "description", Object {}, + false, ], "endIndex": 1760, "event": "opentag", @@ -4554,6 +4742,7 @@ Array [ Object { "data": Array [ "description", + true, ], "endIndex": 1937, "event": "closetag", @@ -4580,6 +4769,7 @@ Array [ "data": Array [ "pubDate", Object {}, + false, ], "endIndex": 1956, "event": "opentag", @@ -4596,6 +4786,7 @@ Array [ Object { "data": Array [ "pubDate", + true, ], "endIndex": 1995, "event": "closetag", @@ -4622,6 +4813,7 @@ Array [ "data": Array [ "guid", Object {}, + false, ], "endIndex": 2011, "event": "opentag", @@ -4638,6 +4830,7 @@ Array [ Object { "data": Array [ "guid", + true, ], "endIndex": 2070, "event": "closetag", @@ -4656,6 +4849,7 @@ Array [ Object { "data": Array [ "item", + true, ], "endIndex": 2085, "event": "closetag", @@ -4682,6 +4876,7 @@ Array [ "data": Array [ "item", Object {}, + false, ], "endIndex": 2098, "event": "opentag", @@ -4708,6 +4903,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 2115, "event": "opentag", @@ -4724,6 +4920,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 2148, "event": "closetag", @@ -4750,6 +4947,7 @@ Array [ "data": Array [ "link", Object {}, + false, ], "endIndex": 2164, "event": "opentag", @@ -4766,6 +4964,7 @@ Array [ Object { "data": Array [ "link", + true, ], "endIndex": 2226, "event": "closetag", @@ -4792,6 +4991,7 @@ Array [ "data": Array [ "description", Object {}, + false, ], "endIndex": 2249, "event": "opentag", @@ -4808,6 +5008,7 @@ Array [ Object { "data": Array [ "description", + true, ], "endIndex": 2430, "event": "closetag", @@ -4834,6 +5035,7 @@ Array [ "data": Array [ "pubDate", Object {}, + false, ], "endIndex": 2449, "event": "opentag", @@ -4850,6 +5052,7 @@ Array [ Object { "data": Array [ "pubDate", + true, ], "endIndex": 2488, "event": "closetag", @@ -4876,6 +5079,7 @@ Array [ "data": Array [ "guid", Object {}, + false, ], "endIndex": 2504, "event": "opentag", @@ -4892,6 +5096,7 @@ Array [ Object { "data": Array [ "guid", + true, ], "endIndex": 2563, "event": "closetag", @@ -4964,6 +5169,7 @@ Array [ "url": "https://picsum.photos/200", "width": "200", }, + false, ], "endIndex": 2662, "event": "opentag", @@ -4972,6 +5178,7 @@ Array [ Object { "data": Array [ "media:content", + true, ], "endIndex": 2662, "event": "closetag", @@ -4989,6 +5196,7 @@ Array [ Object { "data": Array [ "item", + true, ], "endIndex": 2676, "event": "closetag", @@ -5006,6 +5214,7 @@ Array [ Object { "data": Array [ "channel", + true, ], "endIndex": 2690, "event": "closetag", @@ -5023,6 +5232,7 @@ Array [ Object { "data": Array [ "rss", + false, ], "endIndex": 2697, "event": "closetag", @@ -5063,6 +5273,7 @@ Array [ "data": Array [ "html", Object {}, + false, ], "endIndex": 21, "event": "opentag", @@ -5089,6 +5300,7 @@ Array [ "data": Array [ "head", Object {}, + false, ], "endIndex": 28, "event": "opentag", @@ -5115,6 +5327,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 37, "event": "opentag", @@ -5131,6 +5344,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 53, "event": "closetag", @@ -5148,6 +5362,7 @@ Array [ Object { "data": Array [ "head", + true, ], "endIndex": 61, "event": "closetag", @@ -5174,6 +5389,7 @@ Array [ "data": Array [ "body", Object {}, + false, ], "endIndex": 68, "event": "opentag", @@ -5234,6 +5450,7 @@ Array [ "xmlns": "http://www.w3.org/2000/svg", "xmlns:xlink": "http://www.w3.org/1999/xlink", }, + false, ], "endIndex": 167, "event": "opentag", @@ -5260,6 +5477,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 177, "event": "opentag", @@ -5276,6 +5494,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 189, "event": "closetag", @@ -5302,6 +5521,7 @@ Array [ "data": Array [ "animate", Object {}, + false, ], "endIndex": 203, "event": "opentag", @@ -5310,6 +5530,7 @@ Array [ Object { "data": Array [ "animate", + true, ], "endIndex": 203, "event": "closetag", @@ -5336,6 +5557,7 @@ Array [ "data": Array [ "polygon", Object {}, + false, ], "endIndex": 217, "event": "opentag", @@ -5344,6 +5566,7 @@ Array [ Object { "data": Array [ "polygon", + true, ], "endIndex": 217, "event": "closetag", @@ -5370,6 +5593,7 @@ Array [ "data": Array [ "g", Object {}, + false, ], "endIndex": 223, "event": "opentag", @@ -5396,6 +5620,7 @@ Array [ "data": Array [ "path", Object {}, + false, ], "endIndex": 233, "event": "opentag", @@ -5422,6 +5647,7 @@ Array [ "data": Array [ "title", Object {}, + false, ], "endIndex": 245, "event": "opentag", @@ -5438,6 +5664,7 @@ Array [ Object { "data": Array [ "title", + true, ], "endIndex": 254, "event": "closetag", @@ -5464,6 +5691,7 @@ Array [ "data": Array [ "animate", Object {}, + false, ], "endIndex": 270, "event": "opentag", @@ -5472,6 +5700,7 @@ Array [ Object { "data": Array [ "animate", + true, ], "endIndex": 270, "event": "closetag", @@ -5489,6 +5718,7 @@ Array [ Object { "data": Array [ "path", + true, ], "endIndex": 281, "event": "closetag", @@ -5506,6 +5736,7 @@ Array [ Object { "data": Array [ "g", + true, ], "endIndex": 288, "event": "closetag", @@ -5523,6 +5754,7 @@ Array [ Object { "data": Array [ "svg", + true, ], "endIndex": 296, "event": "closetag", @@ -5540,6 +5772,7 @@ Array [ Object { "data": Array [ "body", + true, ], "endIndex": 304, "event": "closetag", @@ -5557,6 +5790,7 @@ Array [ Object { "data": Array [ "html", + false, ], "endIndex": 312, "event": "closetag",