Browse Source

Revert "miniModernizr : encapsulate in self-executing function; add some 1.6 touches"

This reverts commit 6afbf058b4.
pull/14/head
David DeSandro 15 years ago
parent
commit
0592b84b55
  1. 33
      src/mini-modernizr.js

33
src/mini-modernizr.js

@ -41,10 +41,7 @@ var getStyleProperty = (function(){
// <3<3<3 and thanks to Faruk and Paul for doing the heavy lifting // <3<3<3 and thanks to Faruk and Paul for doing the heavy lifting
if ( !window.Modernizr ) { if ( !window.Modernizr ) {
window.Modernizr = (function(window,doc,undefined){ var miniModernizr = {},
var version = '1.6ish: miniModernizr for Molequul',
miniModernizr = {},
vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '), vendorCSSPrefixes = ' -o- -moz- -ms- -webkit- -khtml- '.split(' '),
classes = [], classes = [],
docElement = document.documentElement, docElement = document.documentElement,
@ -59,24 +56,24 @@ if ( !window.Modernizr ) {
{ {
name : 'csstransforms3d', name : 'csstransforms3d',
result : function() { result : function() {
var test = !!getStyleProperty('perspective'); var ret = !!getStyleProperty('perspective');
// double check for Chrome's false positive console.log( ret )
if ( test ){ if (ret){
var st = document.createElement('style'), var st = document.createElement('style'),
div = document.createElement('div'), div = document.createElement('div');
mq = '@media (' + vendorCSSPrefixes.join('transform-3d),(') + 'modernizr)';
st.textContent = mq + '{#modernizr{height:3px}}'; st.textContent = '@media ('+vendorCSSPrefixes.join('transform-3d),(') +
(doc.head || doc.getElementsByTagName('head')[0]).appendChild(st); 'modernizr){#modernizr{height:3px}}';
document.getElementsByTagName('head')[0].appendChild(st);
div.id = 'modernizr'; div.id = 'modernizr';
docElement.appendChild(div); docElement.appendChild(div);
test = div.offsetHeight === 3; ret = div.offsetHeight === 3;
st.parentNode.removeChild(st); st.parentNode.removeChild(st);
div.parentNode.removeChild(div); div.parentNode.removeChild(div);
} }
return !!test; return ret;
} }
}, },
{ {
@ -91,18 +88,16 @@ if ( !window.Modernizr ) {
// Run through all tests and detect their support in the current UA. // Run through all tests and detect their support in the current UA.
for ( var i = 0, len = tests.length; i < len; i++ ) { for ( var i = 0, len = tests.length; i < len; i++ ) {
var test = tests[i], var test = tests[i];
result = test.result(); miniModernizr[ test.name ] = test.result();
miniModernizr[ test.name ] = result; var className = ( test.result() ? '' : 'no-' ) + test.name;
var className = ( result ? '' : 'no-' ) + test.name;
classes.push( className ); classes.push( className );
} }
// Add the new classes to the <html> element. // Add the new classes to the <html> element.
docElement.className += ' ' + classes.join( ' ' ); docElement.className += ' ' + classes.join( ' ' );
return miniModernizr; window.Modernizr = miniModernizr;
})(this,this.document);
} }
Loading…
Cancel
Save