mirror of
https://github.com/ankitects/anki.git
synced 2025-09-21 15:32:23 -04:00
Merge pull request #1062 from abdnh/strip-html-comments
Strip HTML comments from external pastes
This commit is contained in:
commit
7aac1b08d2
1 changed files with 5 additions and 1 deletions
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue