remove comments from HTML to be normalized, fixes final test

pull/787/head
Rich Harris 7 years ago
parent 143d0ea753
commit 2fb0f5078d

@ -75,12 +75,6 @@ function cleanChildren(node) {
// recurse // recurse
[...node.childNodes].forEach(child => { [...node.childNodes].forEach(child => {
if (child.nodeType === 8) {
// comment
node.removeChild(child);
return;
}
if (child.nodeType === 3) { if (child.nodeType === 3) {
// text // text
if ( if (
@ -123,6 +117,7 @@ export function normalizeHtml(window, html) {
try { try {
const node = window.document.createElement('div'); const node = window.document.createElement('div');
node.innerHTML = html node.innerHTML = html
.replace(/<!--.*?-->/g, '')
.replace(/>[\s\r\n]+</g, '><') .replace(/>[\s\r\n]+</g, '><')
.trim(); .trim();
cleanChildren(node, ''); cleanChildren(node, '');

Loading…
Cancel
Save