From 8dccf454fa57dac2b72c207213eca4cd1ecd7a52 Mon Sep 17 00:00:00 2001 From: SassNinja Date: Fri, 19 Oct 2018 09:16:28 +0200 Subject: [PATCH] fix: reset queries in MediaQuery _init method & adjust naming This is necessary because using _reInit would populate the queries with duplicates again otherwise. --- js/foundation.util.mediaQuery.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/js/foundation.util.mediaQuery.js b/js/foundation.util.mediaQuery.js index 69abbc645..970d711e4 100644 --- a/js/foundation.util.mediaQuery.js +++ b/js/foundation.util.mediaQuery.js @@ -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(); }, -- 2.47.2