|
@@ -20,6 +20,7 @@
|
|
|
|
|
|
|
|
/* global Node */
|
|
/* global Node */
|
|
|
|
|
|
|
|
|
|
+
|
|
|
this.serializer = this.serializer || (() => {
|
|
this.serializer = this.serializer || (() => {
|
|
|
|
|
|
|
|
const SELF_CLOSED_TAG_NAMES = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
const SELF_CLOSED_TAG_NAMES = ["area", "base", "br", "col", "command", "embed", "hr", "img", "input", "keygen", "link", "meta", "param", "source", "track", "wbr"];
|
|
@@ -28,6 +29,8 @@ this.serializer = this.serializer || (() => {
|
|
|
const OMITTED_START_TAGS = [
|
|
const OMITTED_START_TAGS = [
|
|
|
{ tagName: "head", accept: element => !element.childNodes.length || element.childNodes[0].nodeType == Node.ELEMENT_NODE },
|
|
{ tagName: "head", accept: element => !element.childNodes.length || element.childNodes[0].nodeType == Node.ELEMENT_NODE },
|
|
|
{ tagName: "body", accept: element => !element.childNodes.length },
|
|
{ tagName: "body", accept: element => !element.childNodes.length },
|
|
|
|
|
+ { tagName: "tbody", accept: element => !element.childNodes[0] && element.childNodes[0].tagName == "TR" },
|
|
|
|
|
+ { tagName: "colgroup", accept: element => !element.childNodes[0] && element.childNodes[0].tagName == "COL" },
|
|
|
];
|
|
];
|
|
|
const OMITTED_END_TAGS = [
|
|
const OMITTED_END_TAGS = [
|
|
|
{ tagName: "html", accept: next => !next || next.nodeType != Node.COMMENT_NODE },
|
|
{ tagName: "html", accept: next => !next || next.nodeType != Node.COMMENT_NODE },
|
|
@@ -35,6 +38,7 @@ this.serializer = this.serializer || (() => {
|
|
|
{ tagName: "body", accept: next => !next || next.nodeType != Node.COMMENT_NODE },
|
|
{ tagName: "body", accept: next => !next || next.nodeType != Node.COMMENT_NODE },
|
|
|
{ tagName: "li", accept: next => !next || ["LI"].includes(next.tagName) },
|
|
{ tagName: "li", accept: next => !next || ["LI"].includes(next.tagName) },
|
|
|
{ tagName: "dt", accept: next => !next || ["DT", "DD"].includes(next.tagName) },
|
|
{ tagName: "dt", accept: next => !next || ["DT", "DD"].includes(next.tagName) },
|
|
|
|
|
+ { tagName: "p", accept: next => next && ["ADDRESS", "ARTICLE", "ASIDE", "BLOCKQUOTE", "DETAILS", "DIV", "DL", "FIELDSET", "FIGCAPTION", "FIGURE", "FOOTER", "FORM", "H1", "H2", "H3", "H4", "H5", "H6", "HEADER", "HR", "MAIN", "NAV", "OL", "P", "PRE", "SECTION", "TABLE", "UL"].includes(next.tagName) },
|
|
|
{ tagName: "dd", accept: next => !next || ["DT", "DD"].includes(next.tagName) },
|
|
{ tagName: "dd", accept: next => !next || ["DT", "DD"].includes(next.tagName) },
|
|
|
{ tagName: "rt", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
|
|
{ tagName: "rt", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
|
|
|
{ tagName: "rp", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
|
|
{ tagName: "rp", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
|