This question is essentially what I'm asking but with the restriction of not removing events for the descendant nodes.
In this fiddle I attempt to remove attached listeners by removing it from the DOM and placing it back.
function removeListeners(el) {
var par = el.parentNode;
var place = el.nextSibling;
par.removeChild(el);
par.insertBefore(el, place);
}
Unfortunately this didn't work, you can still click to get the background to change (which is actually good, I never knew you could attach events without the element being in the DOM).
Given that discovery I tried this
function removeListeners(el) {
var par = el.parentNode;
var clone = el.cloneNode(false);
par.replaceChild(clone, el);
for (var index = 0; index < el.childNodes.length; ++index)
clone.appendChild(el.childNodes[index]);
}
Which tries to do a shallow clone then copy all the decendants back in, but it doesn't copy all the children.
The aforementioned question's answer said that "[if you want to have the children keep their listeners] you'll have to resort to explicitly removing listeners one at a time". I don't know how you would implement that.
I assume he means getting a list of the event types and removing the listeners for each in turn (like jQuery can). Not only would that be impossible for custom events but vanilla JS has no such functionality (you must specify the function to remove).