Merge pull request #1062 from abdnh/strip-html-comments

Strip HTML comments from external pastes
This commit is contained in:
Damien Elmes 2021-03-09 11:55:59 +10:00 committed by GitHub
commit 7aac1b08d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -132,13 +132,17 @@ let filterInternalNode = function (elem: Element) {
// filtering from external sources // filtering from external sources
let filterNode = function (node: Node, extendedMode: boolean): void { let filterNode = function (node: Node, extendedMode: boolean): void {
if (node.nodeType === Node.COMMENT_NODE) {
node.parentNode.removeChild(node);
return;
}
if (!nodeIsElement(node)) { if (!nodeIsElement(node)) {
return; return;
} }
// descend first, and take a copy of the child nodes as the loop will skip // descend first, and take a copy of the child nodes as the loop will skip
// elements due to node modifications otherwise // elements due to node modifications otherwise
for (const child of [...node.children]) { for (const child of [...node.childNodes]) {
filterNode(child, extendedMode); filterNode(child, extendedMode);
} }