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

Fix range error in addFormat if start == end container.

This commit is contained in:
Neil Jenkins 2014-10-03 16:38:20 +07:00
parent b944eb3b3b
commit 73c4146e27
3 changed files with 9 additions and 1 deletions

View file

@ -1709,6 +1709,10 @@ proto._addFormat = function ( tag, attributes, range ) {
} }
if ( textNode === startContainer && startOffset ) { if ( textNode === startContainer && startOffset ) {
textNode = textNode.splitText( startOffset ); textNode = textNode.splitText( startOffset );
if ( endContainer === startContainer ) {
endContainer = textNode;
endOffset -= startOffset;
}
startContainer = textNode; startContainer = textNode;
startOffset = 0; startOffset = 0;
} }

File diff suppressed because one or more lines are too long

View file

@ -624,6 +624,10 @@ proto._addFormat = function ( tag, attributes, range ) {
} }
if ( textNode === startContainer && startOffset ) { if ( textNode === startContainer && startOffset ) {
textNode = textNode.splitText( startOffset ); textNode = textNode.splitText( startOffset );
if ( endContainer === startContainer ) {
endContainer = textNode;
endOffset -= startOffset;
}
startContainer = textNode; startContainer = textNode;
startOffset = 0; startOffset = 0;
} }