]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
fix: reset queries in MediaQuery _init method & adjust naming 11543/head
authorSassNinja <kai.falkowski@gmail.com>
Fri, 19 Oct 2018 07:16:28 +0000 (09:16 +0200)
committerSassNinja <kai.falkowski@gmail.com>
Fri, 19 Oct 2018 07:16:28 +0000 (09:16 +0200)
This is necessary because using _reInit would populate the queries with duplicates again otherwise.

js/foundation.util.mediaQuery.js

index 69abbc645c2bc6eacdfcd1d959f9969a97cec0f1..970d711e4675fc0f5d86780b80fe71960e394d6a 100644 (file)
@@ -81,7 +81,7 @@ var MediaQuery = {
    */
   _init() {
 
-    // make sure the initialization is only done once to avoid overhead when calling _init() several times
+    // make sure the initialization is only done once when calling _init() several times
     if (this.isInitialized === true) {
       return;
     } else {
@@ -99,6 +99,8 @@ var MediaQuery = {
 
     namedQueries = parseStyleToObject(extractedStyles);
 
+    self.queries = []; // reset
+
     for (var key in namedQueries) {
       if(namedQueries.hasOwnProperty(key)) {
         self.queries.push({
@@ -114,11 +116,12 @@ var MediaQuery = {
   },
 
   /**
-   * Reinitializes the media query helper what might be necessary if your CSS is not (completely) loaded while _init() is executed.
+   * Reinitializes the media query helper.
+   * Useful if your CSS breakpoint configuration has just been loaded or has changed since the initialization.
    * @function
    * @private
    */
-  _reinit() {
+  _reInit() {
     this.isInitialized = false;
     this._init();
   },