How about using native XPath methods when they are available, falling
back to how it is done now when those methods are not available?
i.e.
$("//h2", context)
In Firefox / Gecko based browsers:
document.evaluate('//h2', context, null, XPathResult.ANY_TYPE, null)
That would hopefully improve performance. The main problem though is
that more complex XPath expressions that can't be mapped to CSS may be
used.
I am no XPath guru, so would be unsure how to implement this.
There is an implementation for IE in JavaScript (as it does not
support XPath natively): http://sourceforge.net/projects/js-xpath/
Opera 9 supports most of the XPath 1.0 specification. Not sure what
Safari supports though. I can't find any pages on Apple's site listing
the DOM implementation in Safari. Their documention for web developers
seems poor (or I just don't know which pages to go to), although the
API docs are meant to be part of OSX. The only thing I can find is at
http://developer.apple.com/internet/webcontent/index.html
Perhaps as a plugin (as it could add considerably to the code size)?
References:
http://developer.mozilla.org/en/docs/Introduction_to_using_XPath_in_JavaScript
http://developer.mozilla.org/en/docs/DOM:document.evaluate
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/