mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 23:40:35 -05:00
Fix potential infinite loop on cut
Common ancestor of range may change while range is manipulated for deletion.
This commit is contained in:
parent
056133fbdf
commit
45fee4c858
3 changed files with 5 additions and 5 deletions
|
@ -2187,9 +2187,9 @@ var onCut = function ( event ) {
|
||||||
endBlock = getEndBlockOfRange( range, root );
|
endBlock = getEndBlockOfRange( range, root );
|
||||||
copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
|
copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
|
||||||
// Extract the contents
|
// Extract the contents
|
||||||
parent = range.commonAncestorContainer;
|
|
||||||
contents = deleteContentsOfRange( range, root );
|
contents = deleteContentsOfRange( range, root );
|
||||||
// Add any other parents not in extracted content, up to copy root
|
// Add any other parents not in extracted content, up to copy root
|
||||||
|
parent = range.commonAncestorContainer;
|
||||||
if ( parent.nodeType === TEXT_NODE ) {
|
if ( parent.nodeType === TEXT_NODE ) {
|
||||||
parent = parent.parentNode;
|
parent = parent.parentNode;
|
||||||
}
|
}
|
||||||
|
@ -2239,9 +2239,9 @@ var onCopy = function ( event ) {
|
||||||
moveRangeBoundariesDownTree( range );
|
moveRangeBoundariesDownTree( range );
|
||||||
moveRangeBoundariesUpTree( range, copyRoot, copyRoot, root );
|
moveRangeBoundariesUpTree( range, copyRoot, copyRoot, root );
|
||||||
// Extract the contents
|
// Extract the contents
|
||||||
parent = range.commonAncestorContainer;
|
|
||||||
contents = range.cloneContents();
|
contents = range.cloneContents();
|
||||||
// Add any other parents not in extracted content, up to copy root
|
// Add any other parents not in extracted content, up to copy root
|
||||||
|
parent = range.commonAncestorContainer;
|
||||||
if ( parent.nodeType === TEXT_NODE ) {
|
if ( parent.nodeType === TEXT_NODE ) {
|
||||||
parent = parent.parentNode;
|
parent = parent.parentNode;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -57,9 +57,9 @@ var onCut = function ( event ) {
|
||||||
endBlock = getEndBlockOfRange( range, root );
|
endBlock = getEndBlockOfRange( range, root );
|
||||||
copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
|
copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
|
||||||
// Extract the contents
|
// Extract the contents
|
||||||
parent = range.commonAncestorContainer;
|
|
||||||
contents = deleteContentsOfRange( range, root );
|
contents = deleteContentsOfRange( range, root );
|
||||||
// Add any other parents not in extracted content, up to copy root
|
// Add any other parents not in extracted content, up to copy root
|
||||||
|
parent = range.commonAncestorContainer;
|
||||||
if ( parent.nodeType === TEXT_NODE ) {
|
if ( parent.nodeType === TEXT_NODE ) {
|
||||||
parent = parent.parentNode;
|
parent = parent.parentNode;
|
||||||
}
|
}
|
||||||
|
@ -109,9 +109,9 @@ var onCopy = function ( event ) {
|
||||||
moveRangeBoundariesDownTree( range );
|
moveRangeBoundariesDownTree( range );
|
||||||
moveRangeBoundariesUpTree( range, copyRoot, copyRoot, root );
|
moveRangeBoundariesUpTree( range, copyRoot, copyRoot, root );
|
||||||
// Extract the contents
|
// Extract the contents
|
||||||
parent = range.commonAncestorContainer;
|
|
||||||
contents = range.cloneContents();
|
contents = range.cloneContents();
|
||||||
// Add any other parents not in extracted content, up to copy root
|
// Add any other parents not in extracted content, up to copy root
|
||||||
|
parent = range.commonAncestorContainer;
|
||||||
if ( parent.nodeType === TEXT_NODE ) {
|
if ( parent.nodeType === TEXT_NODE ) {
|
||||||
parent = parent.parentNode;
|
parent = parent.parentNode;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue