* Ensure no comment nodes are returned in Selector queries (IE improperly returns comment nodes on getElementsByTagName("*")). Change Element#descendants to use Element#getElementsBySelector in order to avoid this issue. Closes #10220. [Jeff Gobel, Andrew Dupont]

This commit is contained in:
Andrew Dupont 2007-11-27 18:43:56 +00:00
parent b01903d92f
commit c85285496b
4 changed files with 14 additions and 1 deletions

View File

@ -1,3 +1,5 @@
* Ensure no comment nodes are returned in Selector queries (IE improperly returns comment nodes on getElementsByTagName("*")). Change Element#descendants to use Element#getElementsBySelector in order to avoid this issue. Closes #10220. [Jeff Gobel, Andrew Dupont]
* Re-enable the XPath approach in Selector for Safari 3. Falls back to the non-XPath version when it sees a problematic token. [Andrew Dupont]
* Fix a bug in the IE-specific Element#descendantOf logic. [Nicholas, Andrew Dupont]

View File

@ -181,7 +181,7 @@ Element.Methods = {
},
descendants: function(element) {
return $A($(element).getElementsByTagName('*')).each(Element.extend);
return $(element).getElementsBySelector("*");
},
firstDescendant: function(element) {

View File

@ -647,6 +647,16 @@ Object.extend(Selector, {
}
});
if (Prototype.Browser.IE) {
// IE returns comment nodes on getElementsByTagName("*").
// Filter them out.
Selector.handlers.concat = function(a, b) {
for (var i = 0, node; node = b[i]; i++)
if (node.tagName !== "!") a.push(node);
return a;
};
}
function $$() {
return Selector.findChildElements(document, $A(arguments));
}

View File

@ -189,6 +189,7 @@
<span id="nav_test_prev_sibling"></span>
<ul id="navigation_test" style="display: none">
<!-- comment node to screw things up -->
<li class="first"><em>A</em></li>
<li><em class="dim">B</em></li>
<li id="navigation_test_c">