]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
updates performance.now and Date.now polyfills and thrown error types on $.fn.foundation
authorzurbchris <chris@zurb.com>
Wed, 18 Nov 2015 07:20:43 +0000 (23:20 -0800)
committerzurbchris <chris@zurb.com>
Wed, 18 Nov 2015 07:20:43 +0000 (23:20 -0800)
js/foundation.core.js

index 75bf26d28a14e72e7bc9aa17e24183e723cd9ccb..3dff8a16ee9b2e96b4f6ab8ed59ce826ae1465cb 100644 (file)
@@ -247,10 +247,10 @@ var foundation = function(method) {
         });
       }
     }else{//error for no class or no method
-      throw new Error("We're sorry, " + method + " is not an available method for " + (plugClass ? functionName(plugClass) : 'this element') + '.');
+      throw new ReferenceError("We're sorry, '" + method + "' is not an available method for " + (plugClass ? functionName(plugClass) : 'this element') + '.');
     }
   }else{//error for invalid argument type
-    throw new Error("We're sorry, " + type + " is not a valid argument. You must use a string representing the method you wish to invoke.");
+    throw new TypeError("We're sorry, '" + type + "' is not a valid parameter. You must use a string representing the method you wish to invoke.");
   }
   return this;
 };
@@ -260,8 +260,8 @@ $.fn.foundation = foundation;
 
 // Polyfill for requestAnimationFrame
 (function() {
-  if (!Date.now)
-    Date.now = function() { return new Date().getTime(); };
+  if (!Date.now || !window.Date.now)
+    window.Date.now = Date.now = function() { return new Date().getTime(); };
 
   var vendors = ['webkit', 'moz'];
   for (var i = 0; i < vendors.length && !window.requestAnimationFrame; ++i) {
@@ -284,12 +284,18 @@ $.fn.foundation = foundation;
   /**
    * Polyfill for performance.now, required by rAF
    */
-  window.performance = (window.performance || {
-    start: Date.now(),
-    now: function(){
-        return Date.now() - this.start;
-    }
-  });
+  if(!window.performance || !window.performance.now){
+    window.performance = {
+      start: Date.now(),
+      now: function(){ return Date.now() - this.start; }
+    };
+  }
+  // window.performance = (window.performance || {
+  //   start: Date.now(),
+  //   now: function(){
+  //       return Date.now() - this.start;
+  //   }
+  // });
 })();
 
 // Polyfill to get the name of a function in IE9