Permalink
Browse files

Moved forEach implementation to bottom of file

  • Loading branch information...
1 parent 9f68084 commit ebc949c6a6ae916180f17df2f2f9eabfae998b9b @dhotson committed Nov 5, 2012
Showing with 28 additions and 27 deletions.
  1. +28 −27 springy.js
View
55 springy.js
@@ -25,33 +25,6 @@
* OTHER DEALINGS IN THE SOFTWARE.
*/
-//https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
-if ( !Array.prototype.forEach ) {
- Array.prototype.forEach = function( callback, thisArg ) {
- var T, k;
- if ( this == null ) {
- throw new TypeError( " this is null or not defined" );
- }
- var O = Object(this);
- var len = O.length >>> 0; // Hack to convert O.length to a UInt32
- if ( {}.toString.call(callback) != "[object Function]" ) {
- throw new TypeError( callback + " is not a function" );
- }
- if ( thisArg ) {
- T = thisArg;
- }
- k = 0;
- while( k < len ) {
- var kValue;
- if ( k in O ) {
- kValue = O[ k ];
- callback.call( T, kValue, k, O );
- }
- k++;
- }
- };
-}
-
var Graph = function() {
this.nodeSet = {};
this.nodes = [];
@@ -575,3 +548,31 @@ Renderer.prototype.start = function() {
});
};
+// Array.forEach implementation for IE support..
+//https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/forEach
+if ( !Array.prototype.forEach ) {
+ Array.prototype.forEach = function( callback, thisArg ) {
+ var T, k;
+ if ( this == null ) {
+ throw new TypeError( " this is null or not defined" );
+ }
+ var O = Object(this);
+ var len = O.length >>> 0; // Hack to convert O.length to a UInt32
+ if ( {}.toString.call(callback) != "[object Function]" ) {
+ throw new TypeError( callback + " is not a function" );
+ }
+ if ( thisArg ) {
+ T = thisArg;
+ }
+ k = 0;
+ while( k < len ) {
+ var kValue;
+ if ( k in O ) {
+ kValue = O[ k ];
+ callback.call( T, kValue, k, O );
+ }
+ k++;
+ }
+ };
+}
+

0 comments on commit ebc949c

Please sign in to comment.