<commit_before>function removeNode(node) {
    node.parentNode.removeChild(node)
}

export default async function removeScripts({rootElement}) {
    const scripts = Array.from(rootElement.querySelectorAll('script'))
    scripts.forEach(removeNode)

    // TODO Remove event handlers
}<commit_msg>Remove all on* attributes in freeze-dry.<commit_after>function removeNode(node) {
    node.parentNode.removeChild(node)
}

export default async function removeScripts({rootElement}) {
    // Remove all <script> elements.
    const scripts = Array.from(rootElement.querySelectorAll('script'))
    scripts.forEach(removeNode)

    // Remove event handlers (onclick, onload, etcetera).
    const elements = Array.from(rootElement.querySelectorAll('*'))
    elements.forEach(element => {
        // A crude approach: any attribute starting with 'on' is removed.
        Array.from(element.attributes)
            .filter(attribute => attribute.name.startsWith('on'))
            .forEach(attribute => {
                element.removeAttribute(attribute.name)
            })
    })
}
{'fraction_non_alphanumeric': 0.1154562383612663, 'fraction_numerical': 0.0, 'mean_word_length': 3.5358649789029535, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '224889', 'n_tokens_mistral': 284, 'n_tokens_neox': 281, 'n_words': 62}