0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Skip replacing node if type/class match

Replacing the node risks blatting other properties, so safer not to if it
already seems to be the right sort.
This commit is contained in:
Neil Jenkins 2020-01-28 11:15:15 +11:00
parent 9916a4c300
commit 8980c1ac4a
3 changed files with 11 additions and 11 deletions

View file

@ -1961,6 +1961,10 @@ var replaceStyles = function ( node, parent, config ) {
css = style[ attr ];
if ( css && converter.regexp.test( css ) ) {
el = converter.replace( doc, config.classNames, css );
if ( el.nodeName === node.nodeName &&
el.className === node.className ) {
continue;
}
if ( !newTreeTop ) {
newTreeTop = el;
}
@ -1974,11 +1978,7 @@ var replaceStyles = function ( node, parent, config ) {
if ( newTreeTop ) {
newTreeBottom.appendChild( empty( node ) );
if ( node.nodeName === 'SPAN' ) {
parent.replaceChild( newTreeTop, node );
} else {
node.appendChild( newTreeTop );
}
parent.replaceChild( newTreeTop, node );
}
return newTreeBottom || node;

File diff suppressed because one or more lines are too long

View file

@ -92,6 +92,10 @@ var replaceStyles = function ( node, parent, config ) {
css = style[ attr ];
if ( css && converter.regexp.test( css ) ) {
el = converter.replace( doc, config.classNames, css );
if ( el.nodeName === node.nodeName &&
el.className === node.className ) {
continue;
}
if ( !newTreeTop ) {
newTreeTop = el;
}
@ -105,11 +109,7 @@ var replaceStyles = function ( node, parent, config ) {
if ( newTreeTop ) {
newTreeBottom.appendChild( empty( node ) );
if ( node.nodeName === 'SPAN' ) {
parent.replaceChild( newTreeTop, node );
} else {
node.appendChild( newTreeTop );
}
parent.replaceChild( newTreeTop, node );
}
return newTreeBottom || node;