Bug 369341 - gatherTextUnder is a bad treewalker, r=mscott

This commit is contained in:
philringnalda%gmail.com 2007-03-02 04:24:20 +00:00
Родитель 9a67f37181
Коммит 411b180de1
1 изменённых файлов: 11 добавлений и 6 удалений

Просмотреть файл

@ -127,11 +127,10 @@ function gatherTextUnder ( root )
// Add this text to our collection.
text += " " + node.data;
} else if ( node instanceof HTMLImageElement ) {
// If it has an alt= attribute, use that.
// If it has an alt= attribute, add that.
var altText = node.getAttribute( "alt" );
if ( altText && altText != "" ) {
text = altText;
break;
text += " " + altText;
}
}
// Find next node to test.
@ -145,9 +144,15 @@ function gatherTextUnder ( root )
if ( node.nextSibling ) {
node = node.nextSibling;
} else {
// Last resort is our next oldest uncle/aunt.
node = node.parentNode.nextSibling;
depth--;
// Last resort is a sibling of an ancestor.
while ( node && depth > 0 ) {
node = node.parentNode;
depth--;
if ( node.nextSibling ) {
node = node.nextSibling;
break;
}
}
}
}
}