Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | 1x 15x 5x 10x 10x 10x 10x | /**
* @internal
* Remove all forbidden elements from a parsed HTML document
* @param doc The parsed HTML document to clean
* @param forbiddenElements Array of tag names to remove (e.g., ['iframe', 'script'])
*/
export function cleanForbiddenElements(doc: Document, forbiddenElements: string[]): void {
if (forbiddenElements.length === 0) {
return;
}
const selector = forbiddenElements.join(',');
const elements = Array.from(doc.body.querySelectorAll(selector));
for (const element of elements) {
element.parentNode?.removeChild(element);
}
}
|