Skip to content

Commit

Permalink
Making sure files only leak a single variable when we strip the wrapp…
Browse files Browse the repository at this point in the history
…ers. aka Hax.
  • Loading branch information
SlexAxton committed Nov 8, 2012
1 parent 541af0b commit 09ff54f
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/addTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ define(['ModernizrProto', 'Modernizr', 'docElement', 'hasOwnProp'], function( Mo
}

return Modernizr; // allow chaining.
};
}

return addTest;
});
4 changes: 2 additions & 2 deletions src/createElement.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
define(['fnBind'], function() {
var createElement = document.createElement;
return createElement.bind(document);
var createElement = document.createElement.bind(document);
return createElement;
});
24 changes: 13 additions & 11 deletions src/hasOwnProp.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
define(['is'], function( is ) {
// hasOwnProperty shim by kangax needed for Safari 2.0 support
var _hasOwnProperty = ({}).hasOwnProperty;
var hasOwnProp;

if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
hasOwnProp = function (object, property) {
return _hasOwnProperty.call(object, property);
};
}
else {
hasOwnProp = 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) && is(object.constructor.prototype[property], 'undefined'));
};
}
(function() {
var _hasOwnProperty = ({}).hasOwnProperty;
if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
hasOwnProp = function (object, property) {
return _hasOwnProperty.call(object, property);
};
}
else {
hasOwnProp = 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) && is(object.constructor.prototype[property], 'undefined'));
};
}
})();

return hasOwnProp;
});
8 changes: 2 additions & 6 deletions src/injectElementWithStyles.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
define(['ModernizrProto', 'docElement', 'createElement'], function( ModernizrProto, docElement, createElement ) {
// Inject element with style element and some CSS rules
var injectElementWithStyles = function( rule, callback, nodes, testnames ) {
function injectElementWithStyles( rule, callback, nodes, testnames ) {
var mod = 'modernizr';
var style;
var ret;
Expand Down Expand Up @@ -54,11 +54,7 @@ define(['ModernizrProto', 'docElement', 'createElement'], function( ModernizrPro

return !!ret;

};

// Modernizr.testStyles() allows you to add custom styles to the document and test an element afterwards
// Modernizr.testStyles('#modernizr { position:absolute }', function(elem, rule){ ... })
ModernizrProto.testStyles = injectElementWithStyles;
}

return injectElementWithStyles;
});
4 changes: 1 addition & 3 deletions src/modElem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ define(['createElement'], function(createElement) {
/**
* Create our "modernizr" element that we do most feature tests on.
*/
var mod = 'modernizr';
var modElem = createElement(mod);

var modElem = createElement('modernizr');
return modElem;
});
2 changes: 1 addition & 1 deletion src/setClasses.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ define(['Modernizr', 'docElement', 'classes'], function( Modernizr, docElement,
theElem.className = theElem.className.replace(/(^|\s)no-js(\s|$)/, '$1$2') +
// Add the new classes to the <html> element.
(Modernizr._config.enableClasses ? ' js ' + classes.join(' ') : '');
};
}

return setClasses;
});

0 comments on commit 09ff54f

Please sign in to comment.