git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
* Fixed IE ID selectors selecting by the name attribute and added tests
[jquery.git]
/
src
/
selector
/
selector.js
diff --git
a/src/selector/selector.js
b/src/selector/selector.js
index
6a5760a
..
e1abbf4
100644
(file)
--- a/
src/selector/selector.js
+++ b/
src/selector/selector.js
@@
-1,6
+1,6
@@
jQuery.extend({
expr: {
jQuery.extend({
expr: {
- "": "m[2]=='*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
+ "": "m[2]=='*'||jQuery.nodeName(a,m[2])",
"#": "a.getAttribute('id')==m[2]",
":": {
// Position Checks
"#": "a.getAttribute('id')==m[2]",
":": {
// Position Checks
@@
-45,7
+45,7
@@
jQuery.extend({
submit: "a.type=='submit'",
image: "a.type=='image'",
reset: "a.type=='reset'",
submit: "a.type=='submit'",
image: "a.type=='image'",
reset: "a.type=='reset'",
- button: 'a.type=="button"||a.nodeName=="BUTTON"',
+ button: 'a.type=="button"||jQuery.nodeName(a,"button")',
input: "/input|select|textarea|button/i.test(a.nodeName)"
},
".": "jQuery.className.has(a,m[2])",
input: "/input|select|textarea|button/i.test(a.nodeName)"
},
".": "jQuery.className.has(a,m[2])",
@@
-59,7
+59,7
@@
jQuery.extend({
_resort: function(m){
return ["", m[1], m[3], m[2], m[5]];
},
_resort: function(m){
return ["", m[1], m[3], m[2], m[5]];
},
- _prefix: "z=a[m[3]]||jQuery.attr(a,m[3]);"
+ _prefix: "z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQuery.attr(a,m[3]);"
},
"[": "jQuery.find(m[2],a).length"
},
},
"[": "jQuery.find(m[2],a).length"
},
@@
-85,7
+85,7
@@
jQuery.extend({
/^(\+)/, "jQuery.nth(a,2,'nextSibling')",
/^(~)/, function(a){
var s = jQuery.sibling(a.parentNode.firstChild);
/^(\+)/, "jQuery.nth(a,2,'nextSibling')",
/^(~)/, function(a){
var s = jQuery.sibling(a.parentNode.firstChild);
- return s.slice(0, jQuery.inArray(a,s));
+ return s.slice(jQuery.inArray(a,s) + 1);
}
],
}
],
@@
-155,12
+155,13
@@
jQuery.extend({
// Perform our own iteration and filter
jQuery.each( ret, function(){
for ( var c = this.firstChild; c; c = c.nextSibling )
// Perform our own iteration and filter
jQuery.each( ret, function(){
for ( var c = this.firstChild; c; c = c.nextSibling )
- if ( c.nodeType == 1 && ( c.nodeName == m[1].toUpperCase() || m[1] == "*" ) )
+ if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
r.push( c );
});
ret = r;
r.push( c );
});
ret = r;
- t = jQuery.trim( t.replace( re, "" ) );
+ t = t.replace( re, "" );
+ if ( t.indexOf(" ") == 0 ) continue;
foundToken = true;
} else {
// Look for pre-defined expression tokens
foundToken = true;
} else {
// Look for pre-defined expression tokens
@@
-222,11
+223,15
@@
jQuery.extend({
if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
// Optimization for HTML document case
var oid = ret[ret.length-1].getElementById(m[2]);
if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
// Optimization for HTML document case
var oid = ret[ret.length-1].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];
// Do a quick check for node name (where applicable) so
// that div#foo searches will be really fast
// Do a quick check for node name (where applicable) so
// that div#foo searches will be really fast
- ret = r = oid &&
- (!m[3] || oid.nodeName == m[3].toUpperCase()) ? [oid] : [];
+ ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
} else {
// Pre-compile a regular expression to handle class searches
} else {
// Pre-compile a regular expression to handle class searches
@@
-241,7
+246,7
@@
jQuery.extend({
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
// Handle IE7 being really dumb about <object>s
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
// Handle IE7 being really dumb about <object>s
- if ( this.nodeName.toUpperCase() == "OBJECT" && tag == "*" )
+ if ( jQuery.nodeName(this, "object") && tag == "*" )
tag = "param";
jQuery.merge( r,
tag = "param";
jQuery.merge( r,