I need to convert a DOM element to a different type (as in HTML tag name, a
to p
in this case), but still retain all the original elements attributes. Whether they are valid for the new type or not doesn't matter in this case.
Any suggestions on how to do this?
I've looked at just creating a new element and copying the attributes across, but this isn't without it's own complications. In Firefox, DOMElement.attributes
helpfully only includes attributes with a value, but in IE it reports all possible attributes for that element. The attributes
property itself is read-only, so no way to copy that.