here is my situation
I don't want to insert the vdom to the body DOM like bellow codes showing, by the way.
// vdom
const alink = document.createElement('a');
document.body.appendChild(alink);
alink.click();
document.body.removeChild(alink);
const virtualDomConvert = (filename = ``) => {
const svg = document.querySelector(`[id="live_map_svg"]`);
const clone = svg.cloneNode(true);
clone.id = 'vdom_svg';
// autoRemoveAttributes(clone);
const html = clone.outerHTML;
// add xml namespace, support browser open preview
const xml = `
<?xml version="1.0" encoding="UTF-8"?>
${html}
`.trim();
const alink = document.createElement('a');
alink.setAttribute('href', 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(xml));
alink.setAttribute('download', filename);
alink.style.display = 'none';
const vdom = document.createElement(`div`);
vdom.appendChild(alink);
alink.click();
vdom.removeChild(alink);
// ❓ how to delete vdom ???
// vdom.remove();
// vdom.parentElement.removeChild(vdom);
}
I had tried some methods, but still not working.
refs
https://developer.mozilla.org/en-US/docs/Web/API/ChildNode/remove


vdom = undefined;Why are you even deleting a variable?vdomoncevdomis just a variable, you can't remove it. You can let JS garbage collection take care of the created node by assigning anything else tovdomvariable.