Skip to content

Commit

Permalink
expose Modernizr.mq()
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Mar 23, 2011
1 parent 12d5767 commit fe4f688
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
8 changes: 6 additions & 2 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ window.Modernizr = (function(window,document,undefined){
// gist.github.com/786768

// todo: consider using http://javascript.nwbox.com/CSSSupport/css-support.js instead
testMediaQuery = function(mq){
testMediaQuery = (function(mq){

var cache = {},
fakeBody = document.createElement('body'),
Expand Down Expand Up @@ -135,7 +135,7 @@ window.Modernizr = (function(window,document,undefined){
return cache[mq];
};

},
})(),



Expand Down Expand Up @@ -971,6 +971,10 @@ window.Modernizr = (function(window,document,undefined){
// Assign private properties to the return object with prefix
ret._enableHTML5 = enableHTML5;
ret._version = version;


// expose methods
ret.mq = testMediaQuery; // mAYBE???!?!!?

// Remove "no-js" class from <html> element, if it exists:
docElement.className = docElement.className.replace(/\bno-js\b/,'')
Expand Down
17 changes: 15 additions & 2 deletions test/unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ window.TEST = {
// note some unique members of the Modernizr object
inputs : ['input','inputtypes'],
audvid : ['video','audio'],
API : ['addTest'],
API : ['addTest', 'mq'],
privates : ['_enableHTML5','_version','_fontfaceready'],
deprecated : [
{ oldish : 'crosswindowmessaging', newish : 'postmessage'},
Expand Down Expand Up @@ -126,9 +126,12 @@ test('html classes are looking good',function(){
newprops--;
});


equals(classes.length,newprops,'equal number of classes and global object props');

if (classes.length !== newprops){
console.log(classes, modprops);

}

for (var i = 0, len = classes.length, aclass; i <len; i++){
aclass = classes[i];
Expand Down Expand Up @@ -256,6 +259,16 @@ test('Modernizr results match expected values',function(){



test('media query testing',function(){

ok(Modernizr.mq('only screen'),'Modernizr.mq() doesn\' freak out.');

});








Expand Down

0 comments on commit fe4f688

Please sign in to comment.