Skip to content

Commit

Permalink
taking a pass through the test suite with IE8.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Mar 30, 2011
1 parent 5e0657b commit cbbf423
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
2 changes: 1 addition & 1 deletion modernizr.js
Expand Up @@ -840,7 +840,7 @@ window.Modernizr = (function(window,document,undefined){
// then based on that boolean, define an appropriate className // then based on that boolean, define an appropriate className
// and push it into an array of classes we'll join later. // and push it into an array of classes we'll join later.
featurename = feature.toLowerCase(); featurename = feature.toLowerCase();
ret[ featurename ] = tests[ feature ](); ret[ featurename ] = !!tests[ feature ]();


classes.push( ( ret[ featurename ] ? '' : 'no-' ) + featurename ); classes.push( ( ret[ featurename ] ? '' : 'no-' ) + featurename );
} }
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Expand Up @@ -49,7 +49,7 @@ <h2 id="qunit-userAgent"></h2>


<br> <br>
<a href="../output.html">View Modernizr output</a> <a href="../output.html">View Modernizr output</a>

<section><aside>this is an aside within a section</aside></section>
<script> <script>




Expand Down
44 changes: 38 additions & 6 deletions test/unit.js
Expand Up @@ -94,13 +94,12 @@ test('html shim worked', function(){
expect(2); expect(2);


// the exact test we use in the script // the exact test we use in the script
var elem = document.createElement("div"); var elem = document.getElementsByTagName("section")[0];
elem.innerHTML = "<elem style='color:red'></elem>";

ok( elem.childNodes.length === 1 , 'unknown elements dont collapse'); ok( elem.childNodes.length === 1 , 'unknown elements dont collapse');


document.body.appendChild(elem); elem.style.color = 'red';
ok( /red|#ff0000/i.test(elem.childNodes[0].style.color), 'unknown elements are styleable') ok( /red|#ff0000/i.test(elem.style.color), 'unknown elements are styleable')


}); });


Expand Down Expand Up @@ -266,10 +265,43 @@ test('Modernizr results match expected values',function(){




test('Modernizr.mq: media query testing',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.'); 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'); equals(Modernizr.mq('only all'), Modernizr.mq('only all'), 'Cache hit matches');


Expand Down

0 comments on commit cbbf423

Please sign in to comment.