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
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Expand Down
2 changes: 1 addition & 1 deletion test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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>


Expand Down
44 changes: 38 additions & 6 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')

});

Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit cbbf423

Please sign in to comment.