Bug 369341 - gatherTextUnder is a bad treewalker, r+a=mscott
git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@221197 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user