Created
August 10, 2009 01:32
-
-
Save carlwoodward/164972 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Original version. | |
findElements: function(root) { | |
root = root || document; | |
var e = this.expression, results; | |
switch (this.mode) { | |
case 'selectorsAPI': | |
// querySelectorAll queries document-wide, then filters to descendants | |
// of the context element. That's not what we want. | |
// Add an explicit context to the selector if necessary. | |
if (root !== document) { | |
var oldId = root.id, id = $(root).identify(); | |
e = "#" + id + " " + e; | |
} | |
results = $A(root.querySelectorAll(e)).map(Element.extend); | |
root.id = oldId; | |
return results; | |
case 'xpath': | |
return document._getElementsByXPath(this.xpath, root); | |
default: | |
return this.matcher(root); | |
} | |
}, | |
// Changed version to work in safari. | |
findElements: function(root) { | |
root = root || document; | |
var e = this.expression, results; | |
switch (this.mode) { | |
case 'selectorsAPI': | |
// querySelectorAll queries document-wide, then filters to descendants | |
// of the context element. That's not what we want. | |
// Add an explicit context to the selector if necessary. | |
if (root !== document) { | |
//var oldId = root.id, | |
var id = $(root).identify(); | |
e = "#" + id + " " + e; | |
} | |
results = $A(root.querySelectorAll(e)).map(Element.extend); | |
// root.id = oldId; | |
return results; | |
case 'xpath': | |
return document._getElementsByXPath(this.xpath, root); | |
default: | |
return this.matcher(root); | |
} | |
}, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment