Make sure that [name=FOO] searches actually have the specified name (IE includes elements that have the ID, as well).

This commit is contained in:
John Resig 2009-02-15 22:33:19 +00:00
parent 20827707a9
commit 22c9c9b9d3
2 changed files with 16 additions and 2 deletions

View file

@ -332,7 +332,14 @@ var Expr = Sizzle.selectors = {
},
NAME: function(match, context, isXML){
if ( typeof context.getElementsByName !== "undefined" ) {
var ret = context.getElementsByName(match[1]);
var ret = [], results = context.getElementsByName(match[1]);
for ( var i = 0, l = results.length; i < l; i++ ) {
if ( results[i].getAttribute("name") === match[1] ) {
ret.push( results[i] );
}
}
return ret.length === 0 ? null : ret;
}
},