|
|
@ -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, '');
|
|
|
|