mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 23:40:35 -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,15 +1148,16 @@
|
||||||
if ( childLength ) {
|
if ( childLength ) {
|
||||||
cleanTree( child, allowStyles );
|
cleanTree( child, allowStyles );
|
||||||
}
|
}
|
||||||
} else {
|
} else if ( nodeType !== TEXT_NODE || (
|
||||||
if ( ( nodeType !== TEXT_NODE ) ||
|
!( /\S/.test( child.data ) ) &&
|
||||||
!( /\S/.test( child.data ) ) ) {
|
!( i > 0 && children[ i - 1 ].isInline() ) &&
|
||||||
|
!( i + 1 < l && children[ i + 1 ].isInline() )
|
||||||
|
) ) {
|
||||||
node.removeChild( child );
|
node.removeChild( child );
|
||||||
i -= 1;
|
i -= 1;
|
||||||
l -= 1;
|
l -= 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue