To remove all event listener to an element just iterate through the property and nullify event related properties.
E.g: Nullify all property that startWith on
which always denotes event handlers.
for (const property in element) {
if (element[property] && property.startsWith('on')) {
element[property] = null
console.log('cleanup removed listener from ' + element.nodeName, property)
}
}
This also related to what @john-henckel. Also this only applies to a single element, its children won't be affected.