X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;ds=sidebyside;f=src%2Fselector%2Fselector.js;h=856e0f594af2f10fb52e265d0f9a886198012a9a;hb=fde2867fce7b592096ae529ab5dcd0842e52f2ac;hp=e1abbf4f69823790de73b5eb09d6b99f4b106f8b;hpb=44599e174b5d1f924def5a3950375ead12b9d21b;p=jquery.git diff --git a/src/selector/selector.js b/src/selector/selector.js index e1abbf4..856e0f5 100644 --- a/src/selector/selector.js +++ b/src/selector/selector.js @@ -126,7 +126,7 @@ jQuery.extend({ t = t.substr(2,t.length); // And the / root expression - } else if ( !t.indexOf("/") ) { + } else if ( !t.indexOf("/") && !context.ownerDocument ) { context = context.documentElement; t = t.substr(1,t.length); if ( t.indexOf("/") >= 1 ) @@ -219,15 +219,17 @@ jQuery.extend({ m = re2.exec(t); } + var last = ret[ret.length-1]; + // Try to do a global search by ID, where we can - if ( m[1] == "#" && ret[ret.length-1].getElementById ) { + if ( m[1] == "#" && last && last.getElementById ) { // Optimization for HTML document case - var oid = ret[ret.length-1].getElementById(m[2]); + var oid = last.getElementById(m[2]); // Do a quick check for the existence of the actual ID attribute // to avoid selecting by the name attribute in IE if ( jQuery.browser.msie && oid && oid.id != m[2] ) - oid = jQuery('[@id="'+m[2]+'"]', ret[ret.length-1])[0]; + oid = jQuery('[@id="'+m[2]+'"]', last)[0]; // Do a quick check for node name (where applicable) so // that div#foo searches will be really fast