I am looking for guidance on how to clone a Node and then convert its nodeName, ensuring that the attributes are copied along with the children deeply. I want to achieve something similar to switching an existing span element to a div while retaining all its attributes and child elements.
Your help is greatly appreciated!
Once I successfully clone and convert the node to a div, my goal is to replace the original span element with it. Additionally, I am also curious if there is a method to clone all event listeners associated with the element.