Skip to content

Commit 47d28d9

Browse files
committed
Upgrade to the latest matchMedia.js
update
1 parent d7b0245 commit 47d28d9

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

lib/web/matchMedia.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! 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 */
1+
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. MIT license */
22

33
window.matchMedia || (window.matchMedia = function() {
44
"use strict";
@@ -8,14 +8,18 @@ window.matchMedia || (window.matchMedia = function() {
88

99
// For those that don't support matchMedium
1010
if (!styleMedia) {
11-
var style = document.createElement('style'),
12-
script = document.getElementsByTagName('script')[0],
13-
info = null;
11+
var style = document.createElement('style'),
12+
script = document.getElementsByTagName('script')[0],
13+
info = null;
1414

15-
style.type = 'text/css';
16-
style.id = 'matchmediajs-test';
15+
style.type = 'text/css';
16+
style.id = 'matchmediajs-test';
1717

18-
script.parentNode.insertBefore(style, script);
18+
if (!script) {
19+
document.head.appendChild(style);
20+
} else {
21+
script.parentNode.insertBefore(style, script);
22+
}
1923

2024
// 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
2125
info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
@@ -141,4 +145,4 @@ window.mediaCheck = function(options) {
141145
});
142146

143147
mqChange(mq, options);
144-
};
148+
};

0 commit comments

Comments
 (0)