Can it also be changed to take advantage of some browsers XPath parsing abilities (that is how I thought it would have worked when 1.2 came out)? I know Firefox has native parsing (http:// developer.mozilla.org/en/docs/ Introduction_to_using_XPath_in_JavaScript) and so does Internet Explorer (via ActiveX("MSXML.DOMDocument")) - do Opera and Safari?
On Sep 28, 4:17 pm, "John Resig" <[EMAIL PROTECTED]> wrote: > Yes, that's it. We really don't support very much XPath, only a couple > commands. That was a big reason why it was removed, we didn't have to > resources or interest to flush it out into a full XPath > representation. > > --John > > On 9/28/07, Danjojo <[EMAIL PROTECTED]> wrote: > > > > > Is this all I need to add to my external .js library to fully include > > the Xpath plugin? > > > /* > > * Simple XPath Compatibility Plugin for jQuery 1.1 > > * By John Resig > > * Dual licensed under MIT and GPL. > > */ > > > (function(jQuery){ > > > var find = jQuery.find; > > > jQuery.find = function(selector, context){ > > > // Convert the root / into a different context > > if ( !selector.indexOf("/") ) { > > context = context.documentElement; > > selector = selector.replace(/^\/\w*/, ""); > > if ( !selector ) > > return [ context ]; > > } > > > // Convert // to " " > > selector = selector.replace(/\/\//g, " "); > > > // Convert / to > > > selector = selector.replace(/\//g, ">"); > > > // Naively convert [elem] into :has(elem) > > selector = selector.replace(/\[([EMAIL PROTECTED])\]/g, > > function(m, selector){ > > return ":has(" + selector + ")"; > > }); > > > // Naively convert /.. into a new set of expressions > > if ( selector.indexOf(">..") >= 0 ) { > > var parts = selector.split(/>\.\.>?/g); > > var cur = jQuery(parts[0], context); > > > for ( var i = 1; i < parts.length; i++ ) > > cur = cur.parent(parts[i]); > > > return cur.get(); > > } > > > return find(selector, context); > > }; > > > })(jQuery);