Skip to content

Commit

Permalink
undefined is a string itself so it can be used right in the call to i…
Browse files Browse the repository at this point in the history
…s(), thus benefitting from local scope, better minification, and better gzipping.
  • Loading branch information
Phil Dokas committed Oct 27, 2010
1 parent d125248 commit cfe5d96
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
window.Modernizr = (function(window,document,undefined){

var version = '1.6',

ret = {},

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

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

// hasOwnProperty shim by kangax needed for Safari 2.0 support
var _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
if (isDefined(_hasOwnProperty) && isDefined(_hasOwnProperty.call)) {
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) && !isDefined(object.constructor.prototype[property]));
return ((property in object) && is(object.constructor.prototype[property], undefined));
};
}

Expand All @@ -199,20 +199,6 @@ window.Modernizr = (function(window,document,undefined){
return typeof obj === type;
}

/**
* isDefined returns a boolean for if typeof obj is 'undefined'.
*/
function isDefined( obj ) {
return !is(obj, 'undefined');
}

/**
* isFunction returns a boolean for if typeof obj is 'function'.
*/
function isFunction( obj ) {
return is(obj, 'function');
}

/**
* contains returns a boolean for if substr is found within str.
*/
Expand Down Expand Up @@ -306,7 +292,7 @@ window.Modernizr = (function(window,document,undefined){
};

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


Expand Down

0 comments on commit cfe5d96

Please sign in to comment.