File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -332,7 +332,14 @@ var Expr = Sizzle.selectors = {
332
332
} ,
333
333
NAME : function ( match , context , isXML ) {
334
334
if ( typeof context . getElementsByName !== "undefined" ) {
335
- var ret = context . getElementsByName ( match [ 1 ] ) ;
335
+ var ret = [ ] , results = context . getElementsByName ( match [ 1 ] ) ;
336
+
337
+ for ( var i = 0 , l = results . length ; i < l ; i ++ ) {
338
+ if ( results [ i ] . getAttribute ( "name" ) === match [ 1 ] ) {
339
+ ret . push ( results [ i ] ) ;
340
+ }
341
+ }
342
+
336
343
return ret . length === 0 ? null : ret ;
337
344
}
338
345
} ,
Original file line number Diff line number Diff line change @@ -144,7 +144,7 @@ test("class", function() {
144
144
} ) ;
145
145
146
146
test ( "name" , function ( ) {
147
- expect ( 9 ) ;
147
+ expect ( 11 ) ;
148
148
149
149
t ( "Name selector" , "input[name=action]" , [ "text1" ] ) ;
150
150
t ( "Name selector with single quotes" , "input[name='action']" , [ "text1" ] ) ;
@@ -158,6 +158,13 @@ test("name", function() {
158
158
159
159
isSet ( jQuery ( "#form" ) . find ( "input[name=action]" ) , q ( "text1" ) , "Name selector within the context of another element" ) ;
160
160
isSet ( jQuery ( "#form" ) . find ( "input[name='foo[bar]']" ) , q ( "hidden2" ) , "Name selector for grouped form element within the context of another element" ) ;
161
+
162
+ var a = jQuery ( '<a id="tName1ID" name="tName1">tName1 A</a><a id="tName2ID" name="tName2">tName2 A</a><div id="tName1">tName1 Div</div>' ) . appendTo ( '#main' ) ;
163
+
164
+ t ( "Find elements that have similar IDs" , "[name=tName1]" , [ "tName1ID" ] ) ;
165
+ t ( "Find elements that have similar IDs" , "[name=tName2]" , [ "tName2ID" ] ) ;
166
+
167
+ a . remove ( ) ;
161
168
} ) ;
162
169
163
170
You can’t perform that action at this time.
0 commit comments