Permalink
Browse files

taking a pass through the test suite with IE8.

  • Loading branch information...
1 parent 5e0657b commit cbbf423b783b3d7a412aee5504184d739b0c95d4 @paulirish paulirish committed Mar 30, 2011
Showing with 40 additions and 8 deletions.
  1. +1 −1 modernizr.js
  2. +1 −1 test/index.html
  3. +38 −6 test/unit.js
View
@@ -840,7 +840,7 @@ window.Modernizr = (function(window,document,undefined){
// then based on that boolean, define an appropriate className
// and push it into an array of classes we'll join later.
featurename = feature.toLowerCase();
- ret[ featurename ] = tests[ feature ]();
+ ret[ featurename ] = !!tests[ feature ]();
classes.push( ( ret[ featurename ] ? '' : 'no-' ) + featurename );
}
View
@@ -49,7 +49,7 @@ <h2 id="qunit-userAgent"></h2>
<br>
<a href="../output.html">View Modernizr output</a>
-
+ <section><aside>this is an aside within a section</aside></section>
<script>
View
@@ -94,13 +94,12 @@ test('html shim worked', function(){
expect(2);
// the exact test we use in the script
- var elem = document.createElement("div");
- elem.innerHTML = "<elem style='color:red'></elem>";
-
+ var elem = document.getElementsByTagName("section")[0];
+
ok( elem.childNodes.length === 1 , 'unknown elements dont collapse');
- document.body.appendChild(elem);
- ok( /red|#ff0000/i.test(elem.childNodes[0].style.color), 'unknown elements are styleable')
+ elem.style.color = 'red';
+ ok( /red|#ff0000/i.test(elem.style.color), 'unknown elements are styleable')
});
@@ -266,10 +265,43 @@ test('Modernizr results match expected values',function(){
test('Modernizr.mq: media query testing',function(){
+
+ var $html = $('html');
+ $.mobile = {};
+
+ // from jquery mobile
+
+ $.mobile.media = (function() {
+ // TODO: use window.matchMedia once at least one UA implements it
+ var cache = {},
+ testDiv = $( "<div id='jquery-mediatest'>" ),
+ fakeBody = $( "<body>" ).append( testDiv );
+
+ return function( query ) {
+ if ( !( query in cache ) ) {
+ var styleBlock = document.createElement('style'),
+ cssrule = "@media " + query + " { #jquery-mediatest { position:absolute; } }";
+ //must set type for IE!
+ styleBlock.type = "text/css";
+ if (styleBlock.styleSheet){
+ styleBlock.styleSheet.cssText = cssrule;
+ }
+ else {
+ styleBlock.appendChild(document.createTextNode(cssrule));
+ }
+
+ $html.prepend( fakeBody ).prepend( styleBlock );
+ cache[ query ] = testDiv.css( "position" ) === "absolute";
+ fakeBody.add( styleBlock ).remove();
+ }
+ return cache[ query ];
+ };
+ })();
+
ok(Modernizr.mq,'Modernizr.mq() doesn\' freak out.');
- equals(true, Modernizr.mq('only screen'),'screen media query passes');
+ equals($.mobile.media('only screen'), Modernizr.mq('only screen'),'screen media query matches jQuery mobile\'s result');
equals(Modernizr.mq('only all'), Modernizr.mq('only all'), 'Cache hit matches');

0 comments on commit cbbf423

Please sign in to comment.