0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -05:00

Check for redundant WS when ensuring bottom line.

Fixes #55.
This commit is contained in:
Neil Jenkins 2015-03-29 18:56:32 +11:00
parent 4c63ad696e
commit 1b9606452e
3 changed files with 13 additions and 3 deletions

View file

@ -2557,7 +2557,17 @@ var cleanupBRs = function ( root ) {
proto._ensureBottomLine = function () {
var body = this._body,
last = body.lastChild;
last;
// Safari (+others?) adds white-space text nodes to the end of <body>
// for no apparent reason. Remove them, since they're semantically
// meaningless.
while ( last = body.lastChild ) {
if ( last.nodeType === TEXT_NODE && !notWS.test( last.data ) ) {
body.removeChild( last );
} else {
break;
}
}
if ( !last || last.nodeName !== this.defaultBlockTag || !isBlock( last ) ) {
body.appendChild( this.createDefaultBlock() );
}

File diff suppressed because one or more lines are too long

View file

@ -1467,7 +1467,7 @@ var cleanupBRs = function ( root ) {
proto._ensureBottomLine = function () {
var body = this._body,
last = body.lastChild;
last = body.lastElementChild;
if ( !last || last.nodeName !== this.defaultBlockTag || !isBlock( last ) ) {
body.appendChild( this.createDefaultBlock() );
}