Bug Tracker

Changeset 1896

Show
Ignore:
Timestamp:
05/13/07 17:20:03 (2 years ago)
Author:
brandon.aaron
Message:

Fix for #1169

Location:
trunk/jquery
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/jquery/build/test/index.html

    r1827 r1896  
    9393        <form id="lengthtest"> 
    9494            <input type="text" id="length" name="test"> 
     95            <input type="text" id="idTest" name="id"> 
    9596        </form> 
    9697        <table id="table"></table> 
  • trunk/jquery/src/selector/selector.js

    r1842 r1896  
    230230                        // Do a quick check for the existence of the actual ID attribute 
    231231                        // to avoid selecting by the name attribute in IE 
    232                         if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && oid.id != m[2] ) 
     232                        // also check to insure id is a string to avoid selecting an element with the name of 'id' inside a form 
     233                        if ( (jQuery.browser.msie||jQuery.browser.opera) && oid && typeof oid.id == "string" && oid.id != m[2] ) 
    233234                            oid = jQuery('[@id="'+m[2]+'"]', elem)[0]; 
    234235 
  • trunk/jquery/src/selector/selectorTest.js

    r1843 r1896  
    2828 
    2929test("id", function() { 
    30     expect(23); 
     30    expect(24); 
    3131    t( "ID Selector", "#body", ["body"] ); 
    3232    t( "ID Selector w/ Element", "body#body", ["body"] ); 
     
    5656    ok( $("#tName1")[0].id == 'tName1', "ID selector with same value for a name attribute" ); 
    5757    ok( $("#tName2").length == 0, "ID selector non-existing but name attribute on an A tag" ); 
     58    t( "ID Selector on Form with an input that has a name of 'id'", "#lengthtest", ["lengthtest"] ); 
    5859     
    5960    t( "ID selector with non-existant ancestor", "#asdfasdf #foobar", [] ); // bug #986 
     
    111112    t( "Last Child", "p:last-child", ["sap"] ); 
    112113     
    113     t( "Nth-child", "#main form > *:nth-child(2)", ["text2"] ); 
    114     t( "Nth-child", "#main form > :nth-child(2)", ["text2"] ); 
     114    t( "Nth-child", "#main form > *:nth-child(2)", ["text2","idTest"] ); 
     115    t( "Nth-child", "#main form > :nth-child(2)", ["text2","idTest"] ); 
    115116}); 
    116117 
     
    151152    t( "Only Child", "a:only-child", ["simon1","anchor1","yahoo","anchor2"] ); 
    152153    t( "Empty", "ul:empty", ["firstUL"] ); 
    153     t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name","length"] ); 
     154    t( "Enabled UI Element", "input:enabled", ["text1","radio1","radio2","check1","check2","hidden1","hidden2","name","length","idTest"] ); 
    154155    t( "Disabled UI Element", "input:disabled", ["text2"] ); 
    155156    t( "Checked UI Element", "input:checked", ["radio2","check1"] ); 
     
    169170    t( "Position Less Than", "p:lt(3)", ["firstp","ap","sndp"] ); 
    170171    t( "Is A Parent", "p:parent", ["firstp","ap","sndp","en","sap","first"] ); 
    171     t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name","length"] ); 
     172    t( "Is Visible", "input:visible", ["text1","text2","radio1","radio2","check1","check2","name","length","idTest"] ); 
    172173    t( "Is Hidden", "input:hidden", ["hidden1","hidden2"] ); 
    173174     
    174     t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3", "length"] ); 
     175    t( "Form element :input", ":input", ["text1", "text2", "radio1", "radio2", "check1", "check2", "hidden1", "hidden2", "name", "button", "area1", "select1", "select2", "select3", "length", "idTest"] ); 
    175176    t( "Form element :radio", ":radio", ["radio1", "radio2"] ); 
    176177    t( "Form element :checkbox", ":checkbox", ["check1", "check2"] ); 
    177     t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name", "length"] ); 
     178    t( "Form element :text", ":text", ["text1", "text2", "hidden2", "name", "length", "idTest"] ); 
    178179    t( "Form element :radio:checked", ":radio:checked", ["radio2"] ); 
    179180    t( "Form element :checkbox:checked", ":checkbox:checked", ["check1"] );