From 1a36a44e72a0277aae1905fa711beca1d492fcf2 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Wed, 11 Jul 2018 21:13:24 +0200 Subject: [PATCH] chore: update MatchMedia polyfill to v0.3.1 --- js/foundation.util.mediaQuery.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/js/foundation.util.mediaQuery.js b/js/foundation.util.mediaQuery.js index d5ce4079d..6eafabd68 100644 --- a/js/foundation.util.mediaQuery.js +++ b/js/foundation.util.mediaQuery.js @@ -17,9 +17,10 @@ const defaultQueries = { // matchMedia() polyfill - Test a CSS media type/query in JS. -// Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license -window.matchMedia = window.matchMedia || (function() { - 'use strict'; +// Authors & copyright(c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. MIT license +/* eslint-disable */ +window.matchMedia || (window.matchMedia = (function () { + "use strict"; // For browsers that support matchMedium api such as IE 9 and webkit var styleMedia = (window.styleMedia || window.media); @@ -33,14 +34,18 @@ window.matchMedia = window.matchMedia || (function() { style.type = 'text/css'; style.id = 'matchmediajs-test'; - script && script.parentNode && script.parentNode.insertBefore(style, script); + if (!script) { + document.head.appendChild(style); + } else { + script.parentNode.insertBefore(style, script); + } // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle; styleMedia = { - matchMedium(media) { - var text = `@media ${media}{ #matchmediajs-test { width: 1px; } }`; + matchMedium: function (media) { + var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }'; // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers if (style.styleSheet) { @@ -52,7 +57,7 @@ window.matchMedia = window.matchMedia || (function() { // Test if media query is true or false return info.width === '1px'; } - } + }; } return function(media) { @@ -60,8 +65,9 @@ window.matchMedia = window.matchMedia || (function() { matches: styleMedia.matchMedium(media || 'all'), media: media || 'all' }; - } -})(); + }; +})()); +/* eslint-enable */ var MediaQuery = { queries: [], -- 2.47.2