Remove empty lines in visual mode in some more cases

After switching from source mode to visual mode, there will be some
Parsoid-generated white space between block nodes, which remains when
the reply is posted in visual mode.

Follow-up to e064f43499.

Bug: T300439
Change-Id: Ia5d2c06f0a4125e9f148eddd3235f95138c9d37f
This commit is contained in:
Bartosz Dziewoński 2022-01-29 18:53:23 +01:00
parent bacf6a8fc6
commit 6572e108f9

View file

@ -588,10 +588,14 @@ class CommentModifier {
// as nodes are removed.
$childNodeList = iterator_to_array( $container->childNodes );
foreach ( $childNodeList as $node ) {
if (
strtolower( $node->nodeName ) === 'p' &&
if ( (
$node instanceof Text &&
CommentUtils::htmlTrim( $node->nodeValue ?? '' ) === ''
) || (
$node instanceof Element &&
strtolower( $node->tagName ) === 'p' &&
CommentUtils::htmlTrim( DOMCompat::getInnerHTML( $node ) ) === ''
) {
) ) {
$container->removeChild( $node );
}
}