From 26b8033295c3eb4c0c37a94130684b907652dbe7 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Tue, 27 Nov 2007 17:59:46 +0000 Subject: [PATCH] * Fix a bug in the IE-specific Element#descendantOf logic. [Nicholas, Andrew Dupont] --- CHANGELOG | 2 ++ src/dom.js | 3 ++- test/unit/dom.html | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index bac2d0c..ed2dc33 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Fix a bug in the IE-specific Element#descendantOf logic. [Nicholas, Andrew Dupont] + * Make Ajax.Updater clone its options hash before modifying it. Prevents memory leaks in Ajax.PeriodicalUpdater. Closes #10049 [Mislav Marohnić, Tobie Langel]. * Remove useless variable in Selector.handlers.child. Closes #10006 [kuriyama] diff --git a/src/dom.js b/src/dom.js index 599c8ef..a46f841 100644 --- a/src/dom.js +++ b/src/dom.js @@ -359,6 +359,7 @@ Element.Methods = { descendantOf: function(element, ancestor) { element = $(element), ancestor = $(ancestor); + var originalAncestor = ancestor; if (element.compareDocumentPosition) return (element.compareDocumentPosition(ancestor) & 8) === 8; @@ -374,7 +375,7 @@ Element.Methods = { } while (element = element.parentNode) - if (element == ancestor) return true; + if (element == originalAncestor) return true; return false; }, diff --git a/test/unit/dom.html b/test/unit/dom.html index 59d7897..8f7dcc6 100644 --- a/test/unit/dom.html +++ b/test/unit/dom.html @@ -1031,6 +1031,8 @@ assert(!$('sibling').descendantOf('child'), 'sibling < child'); assert(!$('great-grand-child').descendantOf('not-in-the-family'), 'great-grand-child < not-in-the-family'); assert(!$('child').descendantOf('not-in-the-family'), 'child < not-in-the-family'); + + assert(!$(document.body).descendantOf('great-grand-child')); }}, testChildOf: function() {with(this) {