Permalink
Browse files

Streamlining ownLast detection

  • Loading branch information...
1 parent c606c64 commit 394d75e09e5446c49dfcc1389708ab3591764a61 @bjohn465 committed Mar 7, 2013
Showing with 17 additions and 24 deletions.
  1. +1 −1 src/core.js
  2. +7 −14 src/support.js
  3. +9 −9 test/unit/support.js
View
@@ -475,7 +475,7 @@ jQuery.extend({
// Support: IE<9
// Handle iteration over inherited properties before own properties.
- if ( jQuery.support.iteratesOwnLast ) {
+ if ( jQuery.support.ownLast ) {
for( key in obj ) {
return core_hasOwn.call( obj, key );
}
View
@@ -1,8 +1,8 @@
jQuery.support = (function( support ) {
- var all, a, input, select, fragment, opt, eventName, isSupported, i, func,
- props,
- div = document.createElement("div");
+ var all, a, input, select, fragment, opt, eventName, isSupported, i,
+ div = document.createElement("div"),
+ $div = jQuery( div );
// Setup
div.setAttribute( "className", "t" );
@@ -144,17 +144,10 @@ jQuery.support = (function( support ) {
// Support: IE<9
// Iteration over object's inherited properties before its own.
- func = function() {
- this.a = 0;
- };
- func.prototype = {
- b: 1
- };
- props = [];
- for( i in new func() ) {
- props.push( i );
+ for ( i in $div ) {
+ break;
}
- support.iteratesOwnLast = props[0] !== "a";
+ support.ownLast = !core_hasOwn.call( $div, i );
// Run tests that need a body at doc ready
jQuery(function() {
@@ -246,7 +239,7 @@ jQuery.support = (function( support ) {
});
// Null elements to avoid leaks in IE
- all = select = fragment = opt = a = input = func = props = null;
+ all = select = fragment = opt = a = input = $div = null;
return support;
})({});
View
@@ -77,7 +77,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":true,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": true,
- "iteratesOwnLast": false
+ "ownLast": false
};
} else if ( /opera.*version\/12\.1/i.test( userAgent ) ) {
expected = {
@@ -112,7 +112,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":true,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": true,
- "iteratesOwnLast": false
+ "ownLast": false
};
} else if ( /msie 10\.0/i.test( userAgent ) ) {
expected = {
@@ -147,7 +147,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":true,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": false,
- "iteratesOwnLast": false
+ "ownLast": false
};
} else if ( /msie 9\.0/i.test( userAgent ) ) {
expected = {
@@ -182,7 +182,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":false,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": false,
- "iteratesOwnLast": false
+ "ownLast": false
};
} else if ( /msie 8\.0/i.test( userAgent ) ) {
expected = {
@@ -217,7 +217,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":false,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": true,
- "iteratesOwnLast": true
+ "ownLast": true
};
} else if ( /msie 7\.0/i.test( userAgent ) ) {
expected = {
@@ -252,7 +252,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"tbody": false,
"style": false,
"clearCloneStyle": true,
- "iteratesOwnLast": true
+ "ownLast": true
};
} else if ( /msie 6\.0/i.test( userAgent ) ) {
expected = {
@@ -287,7 +287,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":false,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": true,
- "iteratesOwnLast": true
+ "ownLast": true
};
} else if ( /5\.1\.1 safari/i.test( userAgent ) ) {
expected = {
@@ -322,7 +322,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":true,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": true,
- "iteratesOwnLast": false
+ "ownLast": false
};
} else if ( /firefox/i.test( userAgent ) ) {
expected = {
@@ -357,7 +357,7 @@ testIframeWithCallback( "box-sizing does not affect jQuery.support.shrinkWrapBlo
"cors":true,
"doesNotIncludeMarginInBodyOffset":true,
"clearCloneStyle": true,
- "iteratesOwnLast": false
+ "ownLast": false
};
}

0 comments on commit 394d75e

Please sign in to comment.