Bug Tracker

Changeset 1573

Show
Ignore:
Timestamp:
03/24/07 02:54:24 (2 years ago)
Author:
john
Message:

Added fix for #986 (ID selector within an element that doesn't exist).

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/src/selector/selector.js

    r1406 r1573  
    220220                    } 
    221221 
     222                    var last = ret[ret.length-1]; 
     223 
    222224                    // Try to do a global search by ID, where we can 
    223                     if ( m[1] == "#" && ret[ret.length-1].getElementById ) { 
     225                    if ( m[1] == "#" && last && last.getElementById ) { 
    224226                        // Optimization for HTML document case 
    225                         var oid = ret[ret.length-1].getElementById(m[2]); 
     227                        var oid = last.getElementById(m[2]); 
    226228                         
    227229                        // Do a quick check for the existence of the actual ID attribute 
    228230                        // to avoid selecting by the name attribute in IE 
    229231                        if ( jQuery.browser.msie && oid && oid.id != m[2] ) 
    230                             oid = jQuery('[@id="'+m[2]+'"]', ret[ret.length-1])[0]; 
     232                            oid = jQuery('[@id="'+m[2]+'"]', last)[0]; 
    231233 
    232234                        // Do a quick check for node name (where applicable) so