0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2025-01-03 05:00:13 -05:00

Fix Range#containsNode.

Not sufficient for node to be adjacent to range; must actually contain range.
This commit is contained in:
Neil Jenkins 2011-11-02 19:12:31 +11:00
parent 953ee3bfc7
commit e8a917f321
2 changed files with 4 additions and 6 deletions

View file

@ -107,8 +107,6 @@ implement( Text, {
getLength: function () { getLength: function () {
return this.length; return this.length;
}, },
// The text node is essentially its own contents.
empty: function () { return this; },
isLike: function ( node ) { isLike: function ( node ) {
return node.nodeType === TEXT_NODE; return node.nodeType === TEXT_NODE;
}, },

View file

@ -238,18 +238,18 @@ implement( Range, {
// Node must not finish before range starts or start after range // Node must not finish before range starts or start after range
// finishes. // finishes.
var nodeEndBeforeStart = ( range.compareBoundaryPoints( var nodeEndBeforeStart = ( range.compareBoundaryPoints(
END_TO_START, nodeRange ) === 1 ), END_TO_START, nodeRange ) > -1 ),
nodeStartAfterEnd = ( range.compareBoundaryPoints( nodeStartAfterEnd = ( range.compareBoundaryPoints(
START_TO_END, nodeRange ) === -1 ); START_TO_END, nodeRange ) < 1 );
return ( !nodeEndBeforeStart && !nodeStartAfterEnd ); return ( !nodeEndBeforeStart && !nodeStartAfterEnd );
} }
else { else {
// Node must start after range starts and finish before range // Node must start after range starts and finish before range
// finishes // finishes
var nodeStartAfterStart = ( range.compareBoundaryPoints( var nodeStartAfterStart = ( range.compareBoundaryPoints(
START_TO_START, nodeRange ) === -1 ), START_TO_START, nodeRange ) < 1 ),
nodeEndBeforeEnd = ( range.compareBoundaryPoints( nodeEndBeforeEnd = ( range.compareBoundaryPoints(
END_TO_END, nodeRange ) === 1 ); END_TO_END, nodeRange ) > -1 );
return ( nodeStartAfterStart && nodeEndBeforeEnd ); return ( nodeStartAfterStart && nodeEndBeforeEnd );
} }
}, },