|
@@ -32,7 +32,7 @@ this.serializer = this.serializer || (() => {
|
|
|
];
|
|
];
|
|
|
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 },
|
|
|
- { tagName: "head", accept: next => !next || next.nodeType != Node.COMMENT_NODE && (next.nodeType != Node.TEXT_NODE || !spaceFirstCharacter(next.textContent)) },
|
|
|
|
|
|
|
+ { tagName: "head", accept: next => !next || next.nodeType != Node.COMMENT_NODE && (next.nodeType != Node.TEXT_NODE || !startsWithSpaceChar(next.textContent)) },
|
|
|
{ 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) },
|
|
@@ -42,8 +42,8 @@ this.serializer = this.serializer || (() => {
|
|
|
{ tagName: "rp", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
|
|
{ tagName: "rp", accept: next => !next || ["RT", "RP"].includes(next.tagName) },
|
|
|
{ tagName: "optgroup", accept: next => !next || ["OPTGROUP"].includes(next.tagName) },
|
|
{ tagName: "optgroup", accept: next => !next || ["OPTGROUP"].includes(next.tagName) },
|
|
|
{ tagName: "option", accept: next => !next || ["OPTION", "OPTGROUP"].includes(next.tagName) },
|
|
{ tagName: "option", accept: next => !next || ["OPTION", "OPTGROUP"].includes(next.tagName) },
|
|
|
- { tagName: "colgroup", accept: next => !next || next.nodeType != Node.COMMENT_NODE && (next.nodeType != Node.TEXT_NODE || !spaceFirstCharacter(next.textContent)) },
|
|
|
|
|
- { tagName: "caption", accept: next => !next || next.nodeType != Node.COMMENT_NODE && (next.nodeType != Node.TEXT_NODE || !spaceFirstCharacter(next.textContent)) },
|
|
|
|
|
|
|
+ { tagName: "colgroup", accept: next => !next || next.nodeType != Node.COMMENT_NODE && (next.nodeType != Node.TEXT_NODE || !startsWithSpaceChar(next.textContent)) },
|
|
|
|
|
+ { tagName: "caption", accept: next => !next || next.nodeType != Node.COMMENT_NODE && (next.nodeType != Node.TEXT_NODE || !startsWithSpaceChar(next.textContent)) },
|
|
|
{ tagName: "thead", accept: next => !next || ["TBODY", "TFOOT"].includes(next.tagName) },
|
|
{ tagName: "thead", accept: next => !next || ["TBODY", "TFOOT"].includes(next.tagName) },
|
|
|
{ tagName: "tbody", accept: next => !next || ["TBODY", "TFOOT"].includes(next.tagName) },
|
|
{ tagName: "tbody", accept: next => !next || ["TBODY", "TFOOT"].includes(next.tagName) },
|
|
|
{ tagName: "tfoot", accept: next => !next },
|
|
{ tagName: "tfoot", accept: next => !next },
|
|
@@ -150,8 +150,8 @@ this.serializer = this.serializer || (() => {
|
|
|
return content;
|
|
return content;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- function spaceFirstCharacter(textContent) {
|
|
|
|
|
- return Boolean(textContent.charAt(0).match(/ \t\n\f\r+/));
|
|
|
|
|
|
|
+ function startsWithSpaceChar(textContent) {
|
|
|
|
|
+ return Boolean(textContent.match(/^[ \t\n\f\r]/));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
})();
|
|
})();
|