Skip to content

Commit

Permalink
addTest revision. no hasOwnProperty. chainable
Browse files Browse the repository at this point in the history
  • Loading branch information
paulirish committed Apr 21, 2010
1 parent 9de60e2 commit 7fd4fff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions modernizr.js
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,14 @@ window.Modernizr = (function(window,doc,undefined){
* @param test - Function returning true if feature is supported, false if not
*/
ret.addTest = function (feature, test) {
if (this.hasOwnProperty( feature )) {
// warn that feature test is already present
if (ret[ feature ]) {
return; // quit if you're trying to overwrite an existing test
}
feature = feature.toLowerCase();
test = !!(test());
docElement.className += ' ' + (!test ? 'no-' : '') + feature;
ret[ feature ] = test;
return ret; // allow chaining.
};

/**
Expand Down

0 comments on commit 7fd4fff

Please sign in to comment.