(node)
| 41 | const document = parse(html) |
| 42 | |
| 43 | function walk(node) { |
| 44 | if (!node) return false |
| 45 | |
| 46 | if (DROP_TAGS.has(node.nodeName) || (node.nodeName === 'script' && !(node.attrs || []).some(a => a.name === 'src'))) { |
| 47 | const parent = node.parentNode |
| 48 | const idx = parent.childNodes.indexOf(node) |
| 49 | if (idx >= 0) parent.childNodes.splice(idx, 1) |
| 50 | return true |
| 51 | } |
| 52 | |
| 53 | if (node.attrs) { |
| 54 | node.attrs = node.attrs.filter(attr => { |
| 55 | if (DROP_ATTRS.has(attr.name)) return false |
| 56 | if (attr.name === 'class') { |
| 57 | attr.value = filterClassValue(attr.value) |
| 58 | if (!attr.value) return false |
| 59 | } |
| 60 | return true |
| 61 | }) |
| 62 | } |
| 63 | |
| 64 | if (node.childNodes) { |
| 65 | for (let i = node.childNodes.length - 1; i >= 0; i--) { |
| 66 | walk(node.childNodes[i]) |
| 67 | } |
| 68 | } |
| 69 | return false |
| 70 | } |
| 71 | |
| 72 | walk(document) |
| 73 | return serialize(document) |
no test coverage detected