0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Remove redundant <span> after replacing styles

It no CSS left after replacing with semantic equivalent, remove the
whole span.
This commit is contained in:
Neil Jenkins 2023-02-01 13:52:53 +11:00
parent 168033d25d
commit e4ae7c2b81

View file

@ -1,6 +1,6 @@
import { notWS } from './Constants'; import { notWS } from './Constants';
import { TreeIterator, SHOW_ELEMENT_OR_TEXT } from './node/TreeIterator'; import { TreeIterator, SHOW_ELEMENT_OR_TEXT } from './node/TreeIterator';
import { createElement, empty, detach } from './node/Node'; import { createElement, empty, detach, replaceWith } from './node/Node';
import { isInline, isLeaf } from './node/Category'; import { isInline, isLeaf } from './node/Category';
import { fixContainer } from './node/MergeSplit'; import { fixContainer } from './node/MergeSplit';
import { isLineBreak } from './node/Whitespace'; import { isLineBreak } from './node/Whitespace';
@ -95,7 +95,11 @@ const replaceStyles = (
if (newTreeTop && newTreeBottom) { if (newTreeTop && newTreeBottom) {
newTreeBottom.appendChild(empty(node)); newTreeBottom.appendChild(empty(node));
if (node.style.cssText) {
node.appendChild(newTreeTop); node.appendChild(newTreeTop);
} else {
replaceWith(node, newTreeTop);
}
} }
return newTreeBottom || node; return newTreeBottom || node;