Added in jQuery.nodeName() to simplify checking nodeName constantly.
This commit is contained in:
parent
d2f9022a8e
commit
8e105ef931
10
src/jquery/jquery.js
vendored
10
src/jquery/jquery.js
vendored
|
@ -1100,7 +1100,7 @@ jQuery.fn = jQuery.prototype = {
|
||||||
return this.each(function(){
|
return this.each(function(){
|
||||||
var obj = this;
|
var obj = this;
|
||||||
|
|
||||||
if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
|
if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
|
||||||
obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
|
obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
|
||||||
|
|
||||||
jQuery.each( a, function(){
|
jQuery.each( a, function(){
|
||||||
|
@ -1229,6 +1229,10 @@ jQuery.extend({
|
||||||
typeof fn[0] == "undefined" && /function/i.test( fn + "" );
|
typeof fn[0] == "undefined" && /function/i.test( fn + "" );
|
||||||
},
|
},
|
||||||
|
|
||||||
|
nodeName: function( elem, name ) {
|
||||||
|
return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A generic iterator function, which can be used to seemlessly
|
* A generic iterator function, which can be used to seemlessly
|
||||||
* iterate over both objects and arrays. This function is not the same
|
* iterate over both objects and arrays. This function is not the same
|
||||||
|
@ -1451,7 +1455,7 @@ jQuery.extend({
|
||||||
tb = div.childNodes;
|
tb = div.childNodes;
|
||||||
|
|
||||||
for ( var n = tb.length-1; n >= 0 ; --n )
|
for ( var n = tb.length-1; n >= 0 ; --n )
|
||||||
if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
|
if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
|
||||||
tb[n].parentNode.removeChild(tb[n]);
|
tb[n].parentNode.removeChild(tb[n]);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1510,7 +1514,7 @@ jQuery.extend({
|
||||||
if ( value != undefined ) elem[fix[name]] = value;
|
if ( value != undefined ) elem[fix[name]] = value;
|
||||||
return elem[fix[name]];
|
return elem[fix[name]];
|
||||||
|
|
||||||
} else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == "FORM" && (name == "action" || name == "method") )
|
} else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
|
||||||
return elem.getAttributeNode(name).nodeValue;
|
return elem.getAttributeNode(name).nodeValue;
|
||||||
|
|
||||||
// IE elem.getAttribute passes even for style
|
// IE elem.getAttribute passes even for style
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
jQuery.extend({
|
jQuery.extend({
|
||||||
expr: {
|
expr: {
|
||||||
"": "m[2]=='*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
|
"": "m[2]=='*'||jQuery.nodeName(a,m[2])",
|
||||||
"#": "a.getAttribute('id')==m[2]",
|
"#": "a.getAttribute('id')==m[2]",
|
||||||
":": {
|
":": {
|
||||||
// Position Checks
|
// Position Checks
|
||||||
|
@ -45,7 +45,7 @@ jQuery.extend({
|
||||||
submit: "a.type=='submit'",
|
submit: "a.type=='submit'",
|
||||||
image: "a.type=='image'",
|
image: "a.type=='image'",
|
||||||
reset: "a.type=='reset'",
|
reset: "a.type=='reset'",
|
||||||
button: 'a.type=="button"||a.nodeName.toUpperCase()=="BUTTON"',
|
button: 'a.type=="button"||jQuery.nodeName(a,"button")',
|
||||||
input: "/input|select|textarea|button/i.test(a.nodeName)"
|
input: "/input|select|textarea|button/i.test(a.nodeName)"
|
||||||
},
|
},
|
||||||
".": "jQuery.className.has(a,m[2])",
|
".": "jQuery.className.has(a,m[2])",
|
||||||
|
@ -155,7 +155,7 @@ jQuery.extend({
|
||||||
// Perform our own iteration and filter
|
// Perform our own iteration and filter
|
||||||
jQuery.each( ret, function(){
|
jQuery.each( ret, function(){
|
||||||
for ( var c = this.firstChild; c; c = c.nextSibling )
|
for ( var c = this.firstChild; c; c = c.nextSibling )
|
||||||
if ( c.nodeType == 1 && ( c.nodeName.toUpperCase() == m[1].toUpperCase() || m[1] == "*" ) )
|
if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
|
||||||
r.push( c );
|
r.push( c );
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ jQuery.extend({
|
||||||
// Do a quick check for node name (where applicable) so
|
// Do a quick check for node name (where applicable) so
|
||||||
// that div#foo searches will be really fast
|
// that div#foo searches will be really fast
|
||||||
ret = r = oid &&
|
ret = r = oid &&
|
||||||
(!m[3] || oid.nodeName.toUpperCase() == m[3].toUpperCase()) ? [oid] : [];
|
(!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Pre-compile a regular expression to handle class searches
|
// Pre-compile a regular expression to handle class searches
|
||||||
|
@ -242,7 +242,7 @@ jQuery.extend({
|
||||||
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
|
var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
|
||||||
|
|
||||||
// Handle IE7 being really dumb about <object>s
|
// Handle IE7 being really dumb about <object>s
|
||||||
if ( this.nodeName.toUpperCase() == "OBJECT" && tag == "*" )
|
if ( jQuery.nodeName(this, "object") && tag == "*" )
|
||||||
tag = "param";
|
tag = "param";
|
||||||
|
|
||||||
jQuery.merge( r,
|
jQuery.merge( r,
|
||||||
|
|
Loading…
Reference in a new issue