mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Only remove whitespace nodes if between blocks.
* When cleaning the tree we want to remove useless whitespace between block nodes, but we were being a bit too aggressive and removing all whitespace nodes. Now checks the context first.
This commit is contained in:
parent
0bb3c142eb
commit
7162777a0f
2 changed files with 9 additions and 8 deletions
File diff suppressed because one or more lines are too long
|
@ -1148,13 +1148,14 @@
|
|||
if ( childLength ) {
|
||||
cleanTree( child, allowStyles );
|
||||
}
|
||||
} else {
|
||||
if ( ( nodeType !== TEXT_NODE ) ||
|
||||
!( /\S/.test( child.data ) ) ) {
|
||||
node.removeChild( child );
|
||||
i -= 1;
|
||||
l -= 1;
|
||||
}
|
||||
} else if ( nodeType !== TEXT_NODE || (
|
||||
!( /\S/.test( child.data ) ) &&
|
||||
!( i > 0 && children[ i - 1 ].isInline() ) &&
|
||||
!( i + 1 < l && children[ i + 1 ].isInline() )
|
||||
) ) {
|
||||
node.removeChild( child );
|
||||
i -= 1;
|
||||
l -= 1;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
|
|
Loading…
Reference in a new issue