aboutsummaryrefslogtreecommitdiffstats
path: root/src/attributes.js
diff options
context:
space:
mode:
authortimmywil <tim.willison@thisismedium.com>2011-03-17 22:59:05 -0400
committertimmywil <tim.willison@thisismedium.com>2011-04-03 19:13:39 -0400
commitdfeeb872d611c7ff7270fceb7234dd0e04671eb8 (patch)
tree9bf3340894d4070caef440985320b724290a2576 /src/attributes.js
parentd28922bc03ea03dd7f02bbc4abc8061ea4c7305b (diff)
downloadjquery-dfeeb872d611c7ff7270fceb7234dd0e04671eb8.tar.gz
jquery-dfeeb872d611c7ff7270fceb7234dd0e04671eb8.zip
Performance enhancement switching nodeType to a var
Diffstat (limited to 'src/attributes.js')
-rw-r--r--src/attributes.js18
1 files changed, 10 insertions, 8 deletions
diff --git a/src/attributes.js b/src/attributes.js
index 972a02f7f..55d22eb94 100644
--- a/src/attributes.js
+++ b/src/attributes.js
@@ -278,20 +278,20 @@ jQuery.extend({
attrFix: {},
attr: function( elem, name, value, pass ) {
+ var nType = elem.nodeType;
// don't get/set attributes on text, comment and attribute nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined;
}
if ( pass && name in jQuery.attrFn ) {
return jQuery(elem)[name](value);
}
-
- var ret,
- notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
- hooks;
-
+
+ var ret, hooks,
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
+
// Normalize the name if needed
name = notxml && jQuery.attrFix[ name ] || name;
@@ -357,13 +357,15 @@ jQuery.extend({
propFix: {},
prop: function( elem, name, value ) {
+ var nType = elem.nodeType;
// don't get/set properties on text, comment and attribute nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
+ if ( !elem || nType === 3 || nType === 8 || nType === 2 ) {
return undefined;
}
- var ret, hooks, notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem );
+ var ret, hooks,
+ notxml = nType !== 1 || !jQuery.isXMLDoc( elem );
// Try to normalize/fix the name
name = notxml && jQuery.propFix[ name ] || name;