Greatly simplify IE's implementation of Element#descendantOf.
This commit is contained in:
parent
b03d4d40a0
commit
a3f7b712c3
@ -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]
|
||||
|
16
src/dom.js
16
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;
|
||||
},
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user