зеркало из https://github.com/mozilla/pjs.git
Bug 369341 - gatherTextUnder is a bad treewalker, r=mscott
This commit is contained in:
Родитель
9a67f37181
Коммит
411b180de1
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче