0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Clone all attributes when replacing tags

This makes it more likely to preserve the visual result.
This commit is contained in:
Neil Jenkins 2020-01-23 10:17:30 +11:00
parent 2cfba2cf1d
commit af93577405

View file

@ -70,6 +70,12 @@ var styleToSemantic = {
var replaceWithTag = function ( tag ) {
return function ( node, parent ) {
var el = createElement( node.ownerDocument, tag );
var attributes = node.attributes;
var i, l, attribute;
for ( i = 0, l = attributes.length; i < l; i += 1 ) {
attribute = attributes[i];
el.setAttribute( attribute.name, attribute.value );
}
parent.replaceChild( el, node );
el.appendChild( empty( node ) );
return el;