]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Rewrite event listener to make spying possible. 9286/head
authorMarius Olbertz <marius.olbertz@gmail.com>
Sat, 22 Oct 2016 15:17:48 +0000 (17:17 +0200)
committerMarius Olbertz <marius.olbertz@gmail.com>
Sat, 22 Oct 2016 15:17:48 +0000 (17:17 +0200)
Arrow notation makes `bind(this)` statement obsolete, so it can be replaced with an anonymous function calling `_reflow()`, which allows using a `sinon.spy` during the unit tests.

js/foundation.interchange.js

index 2e5b969a623356cdba71494b8fa1bef54ed6ce3b..b43fe93ec360983cdc08e8f4bf07c1c40bfb492c 100644 (file)
@@ -46,7 +46,9 @@ class Interchange {
    * @private
    */
   _events() {
-    $(window).on('resize.zf.interchange', Foundation.util.throttle(this._reflow.bind(this), 50));
+    $(window).on('resize.zf.interchange', Foundation.util.throttle(() => {
+      this._reflow();
+    }, 50));
   }
 
   /**
@@ -61,7 +63,6 @@ class Interchange {
     for (var i in this.rules) {
       if(this.rules.hasOwnProperty(i)) {
         var rule = this.rules[i];
-
         if (window.matchMedia(rule.query).matches) {
           match = rule;
         }