diff options
author | John Resig <jeresig@gmail.com> | 2007-03-24 02:54:24 +0000 |
---|---|---|
committer | John Resig <jeresig@gmail.com> | 2007-03-24 02:54:24 +0000 |
commit | 32b523b5c5f3e2bf40abba2ccf5c7a463ba24b07 (patch) | |
tree | cd26866e7d38cb268f03849d7c69bb127ca6d585 /src | |
parent | e2b52e1e401af05a6fe3ca7bf9e714f973fc4d61 (diff) | |
download | jquery-32b523b5c5f3e2bf40abba2ccf5c7a463ba24b07.tar.gz jquery-32b523b5c5f3e2bf40abba2ccf5c7a463ba24b07.zip |
Added fix for #986 (ID selector within an element that doesn't exist).
Diffstat (limited to 'src')
-rw-r--r-- | src/selector/selector.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/selector/selector.js b/src/selector/selector.js index e1abbf4f6..d59a555ac 100644 --- a/src/selector/selector.js +++ b/src/selector/selector.js @@ -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 |