mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 05:00:13 -05:00
Fix crash in scrollRangeIntoView if no bounding rect
This commit is contained in:
parent
6bafa1d140
commit
9b88aca813
3 changed files with 9 additions and 5 deletions
|
@ -2447,7 +2447,7 @@ proto.scrollRangeIntoView = function ( range ) {
|
||||||
// Get the bounding rect
|
// Get the bounding rect
|
||||||
var rect = range.getBoundingClientRect();
|
var rect = range.getBoundingClientRect();
|
||||||
var node, parent;
|
var node, parent;
|
||||||
if ( !rect.top ) {
|
if ( rect && !rect.top ) {
|
||||||
node = this._doc.createElement( 'SPAN' );
|
node = this._doc.createElement( 'SPAN' );
|
||||||
range = range.cloneRange();
|
range = range.cloneRange();
|
||||||
insertNodeInRange( range, node );
|
insertNodeInRange( range, node );
|
||||||
|
@ -2456,6 +2456,9 @@ proto.scrollRangeIntoView = function ( range ) {
|
||||||
parent.removeChild( node );
|
parent.removeChild( node );
|
||||||
parent.normalize();
|
parent.normalize();
|
||||||
}
|
}
|
||||||
|
if ( !rect ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Then check and scroll
|
// Then check and scroll
|
||||||
var win = this._win;
|
var win = this._win;
|
||||||
var height = win.innerHeight;
|
var height = win.innerHeight;
|
||||||
|
@ -3923,7 +3926,6 @@ proto.removeAllFormatting = function ( range ) {
|
||||||
this._recordUndoState( range );
|
this._recordUndoState( range );
|
||||||
this._getRangeAndRemoveBookmark( range );
|
this._getRangeAndRemoveBookmark( range );
|
||||||
|
|
||||||
|
|
||||||
// Avoid splitting where we're already at edges.
|
// Avoid splitting where we're already at edges.
|
||||||
moveRangeBoundariesUpTree( range, stopNode );
|
moveRangeBoundariesUpTree( range, stopNode );
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -305,7 +305,7 @@ proto.scrollRangeIntoView = function ( range ) {
|
||||||
// Get the bounding rect
|
// Get the bounding rect
|
||||||
var rect = range.getBoundingClientRect();
|
var rect = range.getBoundingClientRect();
|
||||||
var node, parent;
|
var node, parent;
|
||||||
if ( !rect.top ) {
|
if ( rect && !rect.top ) {
|
||||||
node = this._doc.createElement( 'SPAN' );
|
node = this._doc.createElement( 'SPAN' );
|
||||||
range = range.cloneRange();
|
range = range.cloneRange();
|
||||||
insertNodeInRange( range, node );
|
insertNodeInRange( range, node );
|
||||||
|
@ -314,6 +314,9 @@ proto.scrollRangeIntoView = function ( range ) {
|
||||||
parent.removeChild( node );
|
parent.removeChild( node );
|
||||||
parent.normalize();
|
parent.normalize();
|
||||||
}
|
}
|
||||||
|
if ( !rect ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// Then check and scroll
|
// Then check and scroll
|
||||||
var win = this._win;
|
var win = this._win;
|
||||||
var height = win.innerHeight;
|
var height = win.innerHeight;
|
||||||
|
@ -1781,7 +1784,6 @@ proto.removeAllFormatting = function ( range ) {
|
||||||
this._recordUndoState( range );
|
this._recordUndoState( range );
|
||||||
this._getRangeAndRemoveBookmark( range );
|
this._getRangeAndRemoveBookmark( range );
|
||||||
|
|
||||||
|
|
||||||
// Avoid splitting where we're already at edges.
|
// Avoid splitting where we're already at edges.
|
||||||
moveRangeBoundariesUpTree( range, stopNode );
|
moveRangeBoundariesUpTree( range, stopNode );
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue