From 4b2913c79f9d57e96360294d7a134593a8819c91 Mon Sep 17 00:00:00 2001 From: Andrew Dupont Date: Wed, 16 Jul 2008 13:08:52 -0500 Subject: [PATCH] Ensure Selector.handlers.id finds the proper element even when it's not attached to the document. [#198 state:resolved] --- CHANGELOG | 2 ++ src/selector.js | 12 ++---------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 6cb9ae158..e948284f1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Ensure Selector.handlers.id finds the proper element even when it's not attached to the document. [jddalton] + * Fix Position.within in IE. [jddalton] * Fix the deprecated Position.withinIncludingScrollOffsets. [jddalton] diff --git a/src/selector.js b/src/selector.js index 53e3ad27e..7f72f8330 100644 --- a/src/selector.js +++ b/src/selector.js @@ -467,16 +467,8 @@ Object.extend(Selector, { id: function(nodes, root, id, combinator) { var targetNode = $(id), h = Selector.handlers; if (!targetNode) { - var needsToSearch = false; - // IE and Opera don't find elements by ID if they're not attached - // to the document. - if (Prototype.Browser.IE && (root.sourceIndex < 1 || - root === document)) { - needsToSearch = true; - } else if (Prototype.Browser.Opera && - (root.compareDocumentPosition(document) & 1) === 1) { - needsToSearch = true; - } + var needsToSearch = root === document || root.sourceIndex < 1 || + !Element.descendantOf(root, document.documentElement); if (needsToSearch) { var nodes = root.getElementsByTagName('*');