0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 07:13:08 -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:
Neil Jenkins 2017-01-19 17:08:39 +11:00
parent 056133fbdf
commit 45fee4c858
3 changed files with 5 additions and 5 deletions

View file

@ -2187,9 +2187,9 @@ var onCut = function ( event ) {
endBlock = getEndBlockOfRange( range, root );
copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
// Extract the contents
parent = range.commonAncestorContainer;
contents = deleteContentsOfRange( range, root );
// Add any other parents not in extracted content, up to copy root
parent = range.commonAncestorContainer;
if ( parent.nodeType === TEXT_NODE ) {
parent = parent.parentNode;
}
@ -2239,9 +2239,9 @@ var onCopy = function ( event ) {
moveRangeBoundariesDownTree( range );
moveRangeBoundariesUpTree( range, copyRoot, copyRoot, root );
// Extract the contents
parent = range.commonAncestorContainer;
contents = range.cloneContents();
// Add any other parents not in extracted content, up to copy root
parent = range.commonAncestorContainer;
if ( parent.nodeType === TEXT_NODE ) {
parent = parent.parentNode;
}

File diff suppressed because one or more lines are too long

View file

@ -57,9 +57,9 @@ var onCut = function ( event ) {
endBlock = getEndBlockOfRange( range, root );
copyRoot = ( ( startBlock === endBlock ) && startBlock ) || root;
// Extract the contents
parent = range.commonAncestorContainer;
contents = deleteContentsOfRange( range, root );
// Add any other parents not in extracted content, up to copy root
parent = range.commonAncestorContainer;
if ( parent.nodeType === TEXT_NODE ) {
parent = parent.parentNode;
}
@ -109,9 +109,9 @@ var onCopy = function ( event ) {
moveRangeBoundariesDownTree( range );
moveRangeBoundariesUpTree( range, copyRoot, copyRoot, root );
// Extract the contents
parent = range.commonAncestorContainer;
contents = range.cloneContents();
// Add any other parents not in extracted content, up to copy root
parent = range.commonAncestorContainer;
if ( parent.nodeType === TEXT_NODE ) {
parent = parent.parentNode;
}