0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Don't crash removing list if no <li> inside

This commit is contained in:
Neil Jenkins 2018-10-19 11:54:05 +11:00
parent 7cef58bda8
commit 892986b17c
3 changed files with 53 additions and 49 deletions

View file

@ -4086,6 +4086,7 @@ proto.decreaseListLevel = function ( range ) {
var list = listSelection[0];
var startLi = listSelection[1];
var endLi = listSelection[2];
var newParent, next, insertBefore, makeNotList;
if ( !startLi ) {
startLi = list.firstChild;
}
@ -4096,12 +4097,12 @@ proto.decreaseListLevel = function ( range ) {
// Save undo checkpoint and bookmark selection
this._recordUndoState( range, this._isInUndoState );
if ( startLi ) {
// Find the new parent list node
var newParent = list.parentNode;
var next;
newParent = list.parentNode;
// Split list if necesary
var insertBefore = !endLi.nextSibling ?
insertBefore = !endLi.nextSibling ?
list.nextSibling :
split( list, endLi.nextSibling, newParent, root );
@ -4115,7 +4116,7 @@ proto.decreaseListLevel = function ( range ) {
insertBefore = list.parentNode.nextSibling;
}
var makeNotList = !/^[OU]L$/.test( newParent.nodeName );
makeNotList = !/^[OU]L$/.test( newParent.nodeName );
do {
next = startLi === endLi ? null : startLi.nextSibling;
list.removeChild( startLi );
@ -4123,7 +4124,8 @@ proto.decreaseListLevel = function ( range ) {
startLi = this.createDefaultBlock([ empty( startLi ) ]);
}
newParent.insertBefore( startLi, insertBefore );
} while ( ( startLi = next ) );
} while (( startLi = next ));
}
if ( !list.firstChild ) {
detach( list );

File diff suppressed because one or more lines are too long

View file

@ -1550,6 +1550,7 @@ proto.decreaseListLevel = function ( range ) {
var list = listSelection[0];
var startLi = listSelection[1];
var endLi = listSelection[2];
var newParent, next, insertBefore, makeNotList;
if ( !startLi ) {
startLi = list.firstChild;
}
@ -1560,12 +1561,12 @@ proto.decreaseListLevel = function ( range ) {
// Save undo checkpoint and bookmark selection
this._recordUndoState( range, this._isInUndoState );
if ( startLi ) {
// Find the new parent list node
var newParent = list.parentNode;
var next;
newParent = list.parentNode;
// Split list if necesary
var insertBefore = !endLi.nextSibling ?
insertBefore = !endLi.nextSibling ?
list.nextSibling :
split( list, endLi.nextSibling, newParent, root );
@ -1579,7 +1580,7 @@ proto.decreaseListLevel = function ( range ) {
insertBefore = list.parentNode.nextSibling;
}
var makeNotList = !/^[OU]L$/.test( newParent.nodeName );
makeNotList = !/^[OU]L$/.test( newParent.nodeName );
do {
next = startLi === endLi ? null : startLi.nextSibling;
list.removeChild( startLi );
@ -1587,7 +1588,8 @@ proto.decreaseListLevel = function ( range ) {
startLi = this.createDefaultBlock([ empty( startLi ) ]);
}
newParent.insertBefore( startLi, insertBefore );
} while ( ( startLi = next ) );
} while (( startLi = next ));
}
if ( !list.firstChild ) {
detach( list );