mirror of
https://github.com/fastmail/Squire.git
synced 2025-01-03 13:16:31 -05:00
More efficient forEachChildInRange fn.
No need for a tree walker, and we don't waste time iterating into children that can never match the filter function.
This commit is contained in:
parent
8b112b7615
commit
d9872fb4b2
3 changed files with 15 additions and 19 deletions
|
@ -3622,16 +3622,14 @@ proto.setTextDirection = function ( direction ) {
|
||||||
|
|
||||||
|
|
||||||
function forEachChildInRange ( rootNode, range, iterator ) {
|
function forEachChildInRange ( rootNode, range, iterator ) {
|
||||||
var walker = new TreeWalker( rootNode, SHOW_ELEMENT|SHOW_TEXT,
|
var childNodes = rootNode.childNodes,
|
||||||
function ( node ) {
|
node = rootNode.firstChild;
|
||||||
return node.parentNode === rootNode &&
|
while ( node ) {
|
||||||
isNodeContainedInRange( range, node, false /* include partials */ );
|
if ( isNodeContainedInRange( range, node, false ) ) {
|
||||||
}
|
|
||||||
);
|
|
||||||
var node;
|
|
||||||
while ( node = walker.nextNode() ) {
|
|
||||||
iterator( node );
|
iterator( node );
|
||||||
}
|
}
|
||||||
|
node = node.nextSibling;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapEachChildInRange ( rootNode, range, iterator ) {
|
function mapEachChildInRange ( rootNode, range, iterator ) {
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -2164,16 +2164,14 @@ proto.setTextDirection = function ( direction ) {
|
||||||
|
|
||||||
|
|
||||||
function forEachChildInRange ( rootNode, range, iterator ) {
|
function forEachChildInRange ( rootNode, range, iterator ) {
|
||||||
var walker = new TreeWalker( rootNode, SHOW_ELEMENT|SHOW_TEXT,
|
var childNodes = rootNode.childNodes,
|
||||||
function ( node ) {
|
node = rootNode.firstChild;
|
||||||
return node.parentNode === rootNode &&
|
while ( node ) {
|
||||||
isNodeContainedInRange( range, node, false /* include partials */ );
|
if ( isNodeContainedInRange( range, node, false ) ) {
|
||||||
}
|
|
||||||
);
|
|
||||||
var node;
|
|
||||||
while ( node = walker.nextNode() ) {
|
|
||||||
iterator( node );
|
iterator( node );
|
||||||
}
|
}
|
||||||
|
node = node.nextSibling;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapEachChildInRange ( rootNode, range, iterator ) {
|
function mapEachChildInRange ( rootNode, range, iterator ) {
|
||||||
|
|
Loading…
Reference in a new issue