0
Fork 0
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:
Neil Jenkins 2013-02-21 11:37:20 +11:00
parent 0bb3c142eb
commit 7162777a0f
2 changed files with 9 additions and 8 deletions

File diff suppressed because one or more lines are too long

View file

@ -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;