vendor/assets/js/foundation.util.mediaQuery.js.es6 in foundation-rails-6.2.1.0 vs vendor/assets/js/foundation.util.mediaQuery.js.es6 in foundation-rails-6.2.3.0
- old
+ new
@@ -31,14 +31,16 @@
var namedQueries;
namedQueries = parseStyleToObject(extractedStyles);
for (var key in namedQueries) {
- self.queries.push({
- name: key,
- value: `only screen and (min-width: ${namedQueries[key]})`
- });
+ if(namedQueries.hasOwnProperty(key)) {
+ self.queries.push({
+ name: key,
+ value: `only screen and (min-width: ${namedQueries[key]})`
+ });
+ }
}
this.current = this._getCurrentSize();
this._watcher();
@@ -66,12 +68,14 @@
* @param {String} size - Name of the breakpoint to get.
* @returns {String|null} - The media query of the breakpoint, or `null` if the breakpoint doesn't exist.
*/
get(size) {
for (var i in this.queries) {
- var query = this.queries[i];
- if (size === query.name) return query.value;
+ if(this.queries.hasOwnProperty(i)) {
+ var query = this.queries[i];
+ if (size === query.name) return query.value;
+ }
}
return null;
},
@@ -104,17 +108,17 @@
* @function
* @private
*/
_watcher() {
$(window).on('resize.zf.mediaquery', () => {
- var newSize = this._getCurrentSize();
+ var newSize = this._getCurrentSize(), currentSize = this.current;
- if (newSize !== this.current) {
- // Broadcast the media query change on the window
- $(window).trigger('changed.zf.mediaquery', [newSize, this.current]);
-
+ if (newSize !== currentSize) {
// Change the current media query
this.current = newSize;
+
+ // Broadcast the media query change on the window
+ $(window).trigger('changed.zf.mediaquery', [newSize, currentSize]);
}
});
}
};