diff --git a/CHANGELOG b/CHANGELOG index 1db6079..6a827f5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Greatly simplify IE's implementation of Element#descendantOf. + * Prevent exception when using Selector to search for an attribute that is not present. [gryn, Andrew Dupont] * Fix issues where Firefox improperly returns the wrong node from a call to Event.element. Also fixes possible exception in Event.element in IE. [jdalton, Andrew Dupont] diff --git a/src/dom.js b/src/dom.js index be8ff6e..4273378 100644 --- a/src/dom.js +++ b/src/dom.js @@ -363,24 +363,16 @@ Element.Methods = { descendantOf: function(element, ancestor) { element = $(element), ancestor = $(ancestor); - var originalAncestor = ancestor; if (element.compareDocumentPosition) return (element.compareDocumentPosition(ancestor) & 8) === 8; - if (element.sourceIndex && !Prototype.Browser.Opera) { - var e = element.sourceIndex, a = ancestor.sourceIndex, - nextAncestor = ancestor.nextSibling; - if (!nextAncestor) { - do { ancestor = ancestor.parentNode; } - while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode); - } - if (nextAncestor && nextAncestor.sourceIndex) - return (e > a && e < nextAncestor.sourceIndex); - } + if (ancestor.contains) + return ancestor.contains(element); while (element = element.parentNode) - if (element == originalAncestor) return true; + if (element == ancestor) return true; + return false; },