Skip to content

Commit

Permalink
Ensure Selector.handlers.id finds the proper element even when it's n…
Browse files Browse the repository at this point in the history
…ot attached to the document. [#198 state:resolved]
  • Loading branch information
savetheclocktower committed Jul 16, 2008
1 parent 5fffac9 commit 4b2913c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
2 changes: 2 additions & 0 deletions 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]
Expand Down
12 changes: 2 additions & 10 deletions src/selector.js
Expand Up @@ -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('*');
Expand Down

0 comments on commit 4b2913c

Please sign in to comment.