Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

IE is the whiniest fixes #10

  • Loading branch information...
commit 795df180845cabdc99c2d02cd9265d16272ba87a 1 parent af2c54a
@paulirish authored
Showing with 9 additions and 9 deletions.
  1. +9 −9 matchMedia.js
View
18 matchMedia.js
@@ -1,30 +1,30 @@
/*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas. Dual MIT/BSD license */
window.matchMedia = window.matchMedia || (function(doc, undefined){
-
+
var bool,
docElem = doc.documentElement,
refNode = docElem.firstElementChild || docElem.firstChild,
// fakeBody required for <FF4 when executed in <head>
fakeBody = doc.createElement('body'),
div = doc.createElement('div');
-
+
div.id = 'mq-test-1';
div.style.cssText = "position:absolute;top:-100em";
- fakeBody.style.background = "none!important";
+ fakeBody.style.background = "none";
fakeBody.appendChild(div);
-
+
return function(q){
-
+
div.innerHTML = '&shy;<style media="'+q+'"> #mq-test-1 { width: 42px; }</style>';
-
+
docElem.insertBefore(fakeBody, refNode);
- bool = div.offsetWidth == 42;
+ bool = div.offsetWidth == 42;
docElem.removeChild(fakeBody);
-
+
return { matches: bool, media: q };
};
-
+
})(document);
Please sign in to comment.
Something went wrong with that request. Please try again.