I have added an event listener to catch the loading of an SVG after a user action.
HTML
<object id="mySVG" type="image/svg+xml" data="default.svg"></object>
JS
mySVG = document.getElementById('mySVG');
mySVG.addEventListener('load', function () {
// work with SVG contentDocument
});
mySVG.setAttribute('data', 'new.svg');
After another user action, I am clearing out the SVG by loading a blank inline SVG
var svgUrl = URL.createObjectURL(new Blob(['<svg xmlns="http://www.w3.org/2000/svg" width="700" height="700"/>'], {'type':'image/svg+xml'}));
mySVG.setAttribute('data', svgUrl);
I looks like setting this blank SVG is also triggering the load event, which is undesirable. So I tried
mySVG.removeEventListener('load');
This gives me the error
TypeError: Not enough arguments to EventTarget.removeEventListener.
What is the correct syntax for removeEventListener in this context?
edit: method to set the blank SVG was incorrect, corrected after reading this.