mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Fix up ranges in weird cases generated by IE (both start and end to be safe).
This commit is contained in:
parent
4e33a47401
commit
49ca521704
3 changed files with 30 additions and 2 deletions
|
@ -2803,6 +2803,20 @@ proto.hasFormat = function ( tag, attributes, range ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Sanitize range to prevent weird IE artifacts
|
||||
if ( !range.collapsed &&
|
||||
range.startContainer.nodeType === TEXT_NODE &&
|
||||
range.startOffset === range.startContainer.length &&
|
||||
range.startContainer.nextSibling ) {
|
||||
range.setStartBefore( range.startContainer.nextSibling );
|
||||
}
|
||||
if ( !range.collapsed &&
|
||||
range.endContainer.nodeType === TEXT_NODE &&
|
||||
range.endOffset === 0 &&
|
||||
range.endContainer.nextSibling ) {
|
||||
range.setEndAfter( range.endContainer.previousSibling );
|
||||
}
|
||||
|
||||
// If the common ancestor is inside the tag we require, we definitely
|
||||
// have the format.
|
||||
var root = range.commonAncestorContainer,
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -679,6 +679,20 @@ proto.hasFormat = function ( tag, attributes, range ) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// Sanitize range to prevent weird IE artifacts
|
||||
if ( !range.collapsed &&
|
||||
range.startContainer.nodeType === TEXT_NODE &&
|
||||
range.startOffset === range.startContainer.length &&
|
||||
range.startContainer.nextSibling ) {
|
||||
range.setStartBefore( range.startContainer.nextSibling );
|
||||
}
|
||||
if ( !range.collapsed &&
|
||||
range.endContainer.nodeType === TEXT_NODE &&
|
||||
range.endOffset === 0 &&
|
||||
range.endContainer.nextSibling ) {
|
||||
range.setEndAfter( range.endContainer.previousSibling );
|
||||
}
|
||||
|
||||
// If the common ancestor is inside the tag we require, we definitely
|
||||
// have the format.
|
||||
var root = range.commonAncestorContainer,
|
||||
|
|
Loading…
Reference in a new issue