Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pdokas/Modernizr into pdo…
Browse files Browse the repository at this point in the history
…kas-master
  • Loading branch information
paulirish committed Nov 4, 2010
2 parents ee121c4 + cfe5d96 commit b43895d
Showing 1 changed file with 35 additions and 27 deletions.
62 changes: 35 additions & 27 deletions modernizr.js
Expand Up @@ -30,10 +30,10 @@
* @contributor Ben Alman
*/

window.Modernizr = (function(window,doc,undefined){
window.Modernizr = (function(window,document,undefined){

var version = '1.6',

ret = {},

/**
Expand All @@ -53,19 +53,20 @@ window.Modernizr = (function(window,doc,undefined){
enableHTML5 = true,


docElement = doc.documentElement,
docElement = document.documentElement,
docHead = document.getElementsByTagName('head')[0],

/**
* Create our "modernizr" element that we do most feature tests on.
*/
mod = 'modernizr',
m = doc.createElement( mod ),
m = document.createElement( mod ),
m_style = m.style,

/**
* Create the input element for various Web Forms feature tests.
*/
f = doc.createElement( 'input' ),
f = document.createElement( 'input' ),

smile = ':)',

Expand Down Expand Up @@ -102,11 +103,11 @@ window.Modernizr = (function(window,doc,undefined){
testMediaQuery = function(mq){

var st = document.createElement('style'),
div = doc.createElement('div'),
div = document.createElement('div'),
ret;

st.textContent = mq + '{#modernizr{height:3px}}';
(doc.head || doc.getElementsByTagName('head')[0]).appendChild(st);
docHead.appendChild(st);
div.id = 'modernizr';
docElement.appendChild(div);

Expand Down Expand Up @@ -147,10 +148,10 @@ window.Modernizr = (function(window,doc,undefined){
}
if (element.setAttribute && element.removeAttribute) {
element.setAttribute(eventName, '');
isSupported = typeof element[eventName] == 'function';
isSupported = is(element[eventName], 'function');

// If property was created, "remove it" (by setting value to `undefined`)
if (typeof element[eventName] != 'undefined') {
if (!is(element[eventName], undefined)) {
element[eventName] = undefined;
}
element.removeAttribute(eventName);
Expand All @@ -166,14 +167,14 @@ window.Modernizr = (function(window,doc,undefined){

// hasOwnProperty shim by kangax needed for Safari 2.0 support
var _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
if (typeof _hasOwnProperty !== 'undefined' && typeof _hasOwnProperty.call !== 'undefined') {
if (!is(_hasOwnProperty, undefined) && !is(_hasOwnProperty.call, undefined)) {
hasOwnProperty = function (object, property) {
return _hasOwnProperty.call(object, property);
};
}
else {
hasOwnProperty = function (object, property) { /* yes, this can give false positives/negatives, but most of the time we don't care about those */
return ((property in object) && typeof object.constructor.prototype[property] === 'undefined');
return ((property in object) && is(object.constructor.prototype[property], undefined));
};
}

Expand All @@ -191,6 +192,13 @@ window.Modernizr = (function(window,doc,undefined){
return set_css(prefixes.join(str1 + ';') + ( str2 || '' ));
}

/**
* is returns a boolean for if typeof obj is exactly type.
*/
function is( obj, type ) {
return typeof obj === type;
}

/**
* contains returns a boolean for if substr is found within str.
*/
Expand Down Expand Up @@ -258,8 +266,8 @@ window.Modernizr = (function(window,doc,undefined){
element.style.cssText = prefixes.join(property + ':' + value + ';') + (extra || '');
}

var c = doc.createElement('div'),
elem = doc.createElement('div');
var c = document.createElement('div'),
elem = document.createElement('div');

set_prefixed_value_css(c, 'display', 'box', 'width:42px;padding:0;');
set_prefixed_property_css(elem, 'box-flex', '1', 'width:10px;');
Expand All @@ -279,18 +287,18 @@ window.Modernizr = (function(window,doc,undefined){
// http://github.com/Modernizr/Modernizr/issues/issue/97/

tests['canvas'] = function() {
var elem = doc.createElement( 'canvas' );
var elem = document.createElement( 'canvas' );
return !!(elem.getContext && elem.getContext('2d'));
};

tests['canvastext'] = function() {
return !!(ret['canvas'] && typeof doc.createElement( 'canvas' ).getContext('2d').fillText == 'function');
return !!(ret['canvas'] && is(document.createElement( 'canvas' ).getContext('2d').fillText, 'function'));
};


tests['webgl'] = function(){

var elem = doc.createElement( 'canvas' );
var elem = document.createElement( 'canvas' );

try {
if (elem.getContext('webgl')){ return true; }
Expand Down Expand Up @@ -487,7 +495,7 @@ window.Modernizr = (function(window,doc,undefined){

// Note: FF3.0 will false positive on this test
tests['textshadow'] = function(){
return doc.createElement('div').style.textShadow === '';
return document.createElement('div').style.textShadow === '';
};


Expand Down Expand Up @@ -581,9 +589,9 @@ window.Modernizr = (function(window,doc,undefined){

var
sheet,
head = doc.head || doc.getElementsByTagName('head')[0] || docElement,
style = doc.createElement("style"),
impl = doc.implementation || { hasFeature: function() { return false; } };
head = docHead || docElement,
style = document.createElement("style"),
impl = document.implementation || { hasFeature: function() { return false; } };

style.type = 'text/css';
head.insertBefore(style, head.firstChild);
Expand Down Expand Up @@ -638,7 +646,7 @@ window.Modernizr = (function(window,doc,undefined){
// Modernizr does not normalize for that.

tests['video'] = function() {
var elem = doc.createElement('video'),
var elem = document.createElement('video'),
bool = !!elem.canPlayType;

if (bool){
Expand All @@ -656,7 +664,7 @@ window.Modernizr = (function(window,doc,undefined){
};

tests['audio'] = function() {
var elem = doc.createElement('audio'),
var elem = document.createElement('audio'),
bool = !!elem.canPlayType;

if (bool){
Expand Down Expand Up @@ -717,7 +725,7 @@ window.Modernizr = (function(window,doc,undefined){

// Thanks to Erik Dahlstrom
tests['svg'] = function(){
return !!doc.createElementNS && !!doc.createElementNS(ns.svg, "svg").createSVGRect;
return !!document.createElementNS && !!document.createElementNS(ns.svg, "svg").createSVGRect;
};

tests['inlinesvg'] = function() {
Expand All @@ -729,12 +737,12 @@ window.Modernizr = (function(window,doc,undefined){
// Thanks to F1lt3r and lucideer
// http://github.com/Modernizr/Modernizr/issues#issue/35
tests['smil'] = function(){
return !!doc.createElementNS && /SVG/.test(tostring.call(doc.createElementNS(ns.svg,'animate')));
return !!document.createElementNS && /SVG/.test(tostring.call(document.createElementNS(ns.svg,'animate')));
};

tests['svgclippaths'] = function(){
// Possibly returns a false positive in Safari 3.2?
return !!doc.createElementNS && /SVG/.test(tostring.call(doc.createElementNS(ns.svg,'clipPath')));
return !!document.createElementNS && /SVG/.test(tostring.call(document.createElementNS(ns.svg,'clipPath')));
};


Expand Down Expand Up @@ -776,7 +784,7 @@ window.Modernizr = (function(window,doc,undefined){
if (/^range$/.test(f.type) && f.style.WebkitAppearance !== undefined){

docElement.appendChild(f);
var defaultView = doc.defaultView;
var defaultView = document.defaultView;

// Safari 2-4 allows the smiley as a value, despite making a slider
bool = defaultView.getComputedStyle &&
Expand Down Expand Up @@ -873,7 +881,7 @@ window.Modernizr = (function(window,doc,undefined){
// Enable HTML 5 elements for styling in IE.
// fyi: jscript version does not reflect trident version
// therefore ie9 in ie7 mode will still have a jScript v.9
if ( enableHTML5 && window.attachEvent && (function(){ var elem = doc.createElement("div");
if ( enableHTML5 && window.attachEvent && (function(){ var elem = document.createElement("div");
elem.innerHTML = "<elem></elem>";
return elem.childNodes.length !== 1; })()) {
// iepp v1.6 by @jon_neal : code.google.com/p/ie-print-protector
Expand Down

0 comments on commit b43895d

Please sign in to comment.