Permalink
Browse files

Merge branch 'grunt' of https://github.com/sindresorhus/Modernizr int…

…o sindresorhus-grunt

* 'grunt' of https://github.com/sindresorhus/Modernizr:
  Close GH-1: Match Modernizr's current style as close as possible!.
  Forgot to remove the old build script
  Add grunt

Conflicts:
	modernizr.js
  • Loading branch information...
2 parents 928edb7 + b389d0b commit a16c9f769ba16b427305c6ef6b615c8c9e6138fc @ryanseddon ryanseddon committed Jun 25, 2012
View
15 compress.sh
@@ -1,15 +0,0 @@
-#/bin/sh
-
-# sudo npm install -g uglify-js
-
-IN=modernizr.js
-OUT=modernizr.min.js
-
-SIZE_MIN=$(uglifyjs "$IN" --extra --unsafe | tee "$OUT" | wc -c)
-SIZE_GZIP=$(gzip -nfc --best "$OUT" | wc -c)
-
-echo $SIZE_MIN bytes minified, $SIZE_GZIP bytes gzipped
-
-if [ "$1" == "--test" ]; then
- rm "$OUT"
-fi
View
2 feature-detects/canvas-todataurl-type.js
@@ -24,5 +24,5 @@
});
};
- image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg=='
+ image.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==';
}());
View
2 feature-detects/cors.js
@@ -1,3 +1,3 @@
// cors
// By Theodoor van Donge
-Modernizr.addTest('cors', 'withCredentials' in new XMLHttpRequest);
+Modernizr.addTest('cors', 'withCredentials' in new XMLHttpRequest());
View
2 feature-detects/css-calc.js
@@ -5,6 +5,6 @@ Modernizr.addTest('csscalc', function(el, prop, value) {
prop = 'width:';
value = 'calc(10px);';
el = document.createElement('div');
- el.style.cssText = prop + Modernizr._prefixes.join(value + prop)
+ el.style.cssText = prop + Modernizr._prefixes.join(value + prop);
return !!el.style.length;
});
View
2 feature-detects/css-cubicbezierrange.js
@@ -2,7 +2,7 @@
// By @calvein
Modernizr.addTest('cubicbezierrange', function() {
- el = document.createElement('div');
+ var el = document.createElement('div');
el.style.cssText = Modernizr._prefixes.join('transition-timing-function' + ':cubic-bezier(1,0,0,1.1); ');
return !!el.style.length;
});
View
36 feature-detects/css-hyphens.js
@@ -1,15 +1,15 @@
-/* see http://davidnewton.ca/the-current-state-of-hyphenation-on-the-web
- http://davidnewton.ca/demos/hyphenation/test.html
+/* see http://davidnewton.ca/the-current-state-of-hyphenation-on-the-web
+ http://davidnewton.ca/demos/hyphenation/test.html
There are three tests:
- 1. csshyphens - tests hyphens:auto actually adds hyphens to text
- 2. softhyphens - tests that ­ does its job
- 3. softhyphensfind - tests that in-browser Find functionality still works correctly with ­
+ 1. csshyphens - tests hyphens:auto actually adds hyphens to text
+ 2. softhyphens - tests that ­ does its job
+ 3. softhyphensfind - tests that in-browser Find functionality still works correctly with ­
-These tests currently require document.body to be present
+These tests currently require document.body to be present
-Hyphenation is language specific, sometimes.
+Hyphenation is language specific, sometimes.
See for more details: http://code.google.com/p/hyphenator/source/diff?spec=svn975&r=975&format=side&path=/trunk/Hyphenator.js#sc_svn975_313
If loading Hyphenator.js via Modernizr.load, be cautious of issue 158: http://code.google.com/p/hyphenator/issues/detail?id=158
@@ -21,7 +21,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
(function() {
if (!document.body){
- window.console && console.warn('document.body doesn\'t exist. Modernizr hyphens test needs it.')
+ window.console && console.warn('document.body doesn\'t exist. Modernizr hyphens test needs it.');
return;
}
@@ -37,21 +37,21 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
spanWidth = 0,
result = false,
firstChild = document.body.firstElementChild || document.body.firstChild;
-
+
div.appendChild(span);
span.innerHTML = 'Bacon ipsum dolor sit amet jerky velit in culpa hamburger et. Laborum dolor proident, enim dolore duis commodo et strip steak. Salami anim et, veniam consectetur dolore qui tenderloin jowl velit sirloin. Et ad culpa, fatback cillum jowl ball tip ham hock nulla short ribs pariatur aute. Pig pancetta ham bresaola, ut boudin nostrud commodo flank esse cow tongue culpa. Pork belly bresaola enim pig, ea consectetur nisi. Fugiat officia turkey, ea cow jowl pariatur ullamco proident do laborum velit sausage. Magna biltong sint tri-tip commodo sed bacon, esse proident aliquip. Ullamco ham sint fugiat, velit in enim sed mollit nulla cow ut adipisicing nostrud consectetur. Proident dolore beef ribs, laborum nostrud meatball ea laboris rump cupidatat labore culpa. Shankle minim beef, velit sint cupidatat fugiat tenderloin pig et ball tip. Ut cow fatback salami, bacon ball tip et in shank strip steak bresaola. In ut pork belly sed mollit tri-tip magna culpa veniam, short ribs qui in andouille ham consequat. Dolore bacon t-bone, velit short ribs enim strip steak nulla. Voluptate labore ut, biltong swine irure jerky. Cupidatat excepteur aliquip salami dolore. Ball tip strip steak in pork dolor. Ad in esse biltong. Dolore tenderloin exercitation ad pork loin t-bone, dolore in chicken ball tip qui pig. Ut culpa tongue, sint ribeye dolore ex shank voluptate hamburger. Jowl et tempor, boudin pork chop labore ham hock drumstick consectetur tri-tip elit swine meatball chicken ground round. Proident shankle mollit dolore. Shoulder ut duis t-bone quis reprehenderit. Meatloaf dolore minim strip steak, laboris ea aute bacon beef ribs elit shank in veniam drumstick qui. Ex laboris meatball cow tongue pork belly. Ea ball tip reprehenderit pig, sed fatback boudin dolore flank aliquip laboris eu quis. Beef ribs duis beef, cow corned beef adipisicing commodo nisi deserunt exercitation. Cillum dolor t-bone spare ribs, ham hock est sirloin. Brisket irure meatloaf in, boudin pork belly sirloin ball tip. Sirloin sint irure nisi nostrud aliqua. Nostrud nulla aute, enim officia culpa ham hock. Aliqua reprehenderit dolore sunt nostrud sausage, ea boudin pork loin ut t-bone ham tempor. Tri-tip et pancetta drumstick laborum. Ham hock magna do nostrud in proident. Ex ground round fatback, venison non ribeye in.';
document.body.insertBefore(div, firstChild);
-
+
/* get size of unhyphenated text */
divStyle.cssText = 'position:absolute;top:0;left:0;width:5em;text-align:justify;text-justification:newspaper;';
spanHeight = span.offsetHeight;
spanWidth = span.offsetWidth;
/* compare size with hyphenated text */
divStyle.cssText = 'position:absolute;top:0;left:0;width:5em;text-align:justify;'+
- 'text-justification:newspaper;'
- + Modernizr._prefixes.join('hyphens:auto; ');
+ 'text-justification:newspaper;'+
+ Modernizr._prefixes.join('hyphens:auto; ');
result = (span.offsetHeight != spanHeight || span.offsetWidth != spanWidth);
@@ -82,8 +82,8 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
divStyle.cssText = 'position:absolute;top:0;left:0;overflow:visible;width:1.25em;';
div.appendChild(span);
document.body.insertBefore(div, firstChild);
-
-
+
+
/* get height of unwrapped text */
span.innerHTML = 'mm';
spanSize = span.offsetHeight;
@@ -110,7 +110,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
if (result1 === true && result2 === true) { result = true; }
document.body.removeChild(div);
div.removeChild(span);
-
+
return result;
} catch(e) {
return false;
@@ -136,7 +136,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
document.body.insertBefore(div, firstChild);
document.body.insertBefore(dummy, div);
-
+
/* reset the selection to the dummy input element, i.e. BEFORE the div container
* stackoverflow.com/questions/499126/jquery-set-cursor-position-in-text-area */
if (dummy.setSelectionRange) {
@@ -155,7 +155,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
result = window.find(testword + testword);
} else {
try {
- textrange = self.document.body.createTextRange();
+ textrange = window.self.document.body.createTextRange();
result = textrange.findText(testword + testword);
} catch(e) {
result = false;
@@ -188,7 +188,7 @@ More details at https://github.com/Modernizr/Modernizr/issues/312
Modernizr.addTest("softhyphens", function() {
try {
// use numeric entity instead of ­ in case it's XHTML
- return test_hyphens('­', true) && test_hyphens('​', false);
+ return test_hyphens('­', true) && test_hyphens('​', false);
} catch(e) {
return false;
}
View
4 feature-detects/css-remunit.js
@@ -1,7 +1,7 @@
// test by github.com/nsfmc
-// "The 'rem' unit ('root em') is relative to the computed
+// "The 'rem' unit ('root em') is relative to the computed
// value of the 'font-size' value of the root element."
// http://www.w3.org/TR/css3-values/#relative0
// you can test by checking if the prop was ditched
@@ -14,6 +14,6 @@ Modernizr.addTest('cssremunit', function(){
try {
div.style.fontSize = '3rem';
} catch(er){}
- return /rem/.test(div.style.fontSize)
+ return (/rem/).test(div.style.fontSize);
});
View
12 feature-detects/css-scrollbars.js
@@ -1,19 +1,19 @@
// Stylable scrollbars detection
Modernizr.addTest('cssscrollbar', function() {
-
+
var bool,
-
- styles = "#modernizr{overflow: scroll; width: 40px }#" +
- Modernizr._prefixes
+
+ styles = "#modernizr{overflow: scroll; width: 40px }#" +
+ Modernizr._prefixes
.join("scrollbar{width:0px}"+' #modernizr::')
.split('#')
.slice(1)
.join('#') + "scrollbar{width:0px}";
-
+
Modernizr.testStyles(styles, function(node) {
bool = 'scrollWidth' in node && node.scrollWidth == 40;
});
-
+
return bool;
});
View
4 feature-detects/elem-progress-meter.js
@@ -2,10 +2,10 @@
//tests for progressbar-support. All browsers that don't support progressbar returns undefined =)
Modernizr.addTest("progressbar",function(){
- return document.createElement('progress').max != undefined;
+ return document.createElement('progress').max !== undefined;
});
//tests for meter-support. All browsers that don't support meters returns undefined =)
Modernizr.addTest("meter",function(){
- return document.createElement('meter').max != undefined;
+ return document.createElement('meter').max !== undefined;
});
View
6 feature-detects/elem-ruby.js
@@ -17,10 +17,10 @@ Modernizr.addTest('ruby', function () {
docElement.appendChild(ruby);
// browsers that support <ruby> hide the <rp> via "display:none"
- if ( getStyle(rp, displayStyleProperty) == 'none' // for non-IE browsers
+ if ( getStyle(rp, displayStyleProperty) == 'none' || // for non-IE browsers
// but in IE browsers <rp> has "display:inline" so, the test needs other conditions:
- || getStyle(ruby, displayStyleProperty) == 'ruby' && getStyle(rt, displayStyleProperty) == 'ruby-text' // for IE8 & IE9
- || getStyle(rp, fontSizeStyleProperty) == '6pt' && getStyle(rt, fontSizeStyleProperty) == '6pt' ) { // for IE6 & IE7
+ getStyle(ruby, displayStyleProperty) == 'ruby' && getStyle(rt, displayStyleProperty) == 'ruby-text' || // for IE8 & IE9
+ getStyle(rp, fontSizeStyleProperty) == '6pt' && getStyle(rt, fontSizeStyleProperty) == '6pt' ) { // for IE6 & IE7
cleanUp();
return true;
View
2 feature-detects/emoji.js
@@ -7,5 +7,5 @@ Modernizr.addTest('emoji', function() {
ctx.textBaseline = 'top';
ctx.font = '32px Arial';
ctx.fillText('\ud83d\ude03', 0, 0); // "smiling face with open mouth" emoji
- return ctx.getImageData(16, 16, 1, 1).data[0] != 0;
+ return ctx.getImageData(16, 16, 1, 1).data[0] !== 0;
});
View
4 feature-detects/event-deviceorientation-motion.js
@@ -1,5 +1,5 @@
-//By Shi Chuan
-//Part of Device Access aspect of HTML5, same category as geolocation
+//By Shi Chuan
+//Part of Device Access aspect of HTML5, same category as geolocation
//W3C Editor's Draft at http://dev.w3.org/geo/api/spec-source-orientation.html
//Implementation by iOS Safari at http://goo.gl/fhce3 and http://goo.gl/rLKz8
View
8 feature-detects/network-connection.js
@@ -13,10 +13,10 @@
// for more rigorous network testing, consider boomerang.js: github.com/bluesmoon/boomerang/
Modernizr.addTest('lowbandwidth', function() {
-
+
var connection = navigator.connection || { type: 0 }; // polyfill
- return connection.type == 3 // connection.CELL_2G
- || connection.type == 4 // connection.CELL_3G
- || /^[23]g$/.test(connection.type); // string value in new spec
+ return connection.type == 3 || // connection.CELL_2G
+ connection.type == 4 || // connection.CELL_3G
+ /^[23]g$/.test(connection.type); // string value in new spec
});
View
14 feature-detects/webgl-extensions.js
@@ -12,8 +12,8 @@
var canvas, ctx, exts;
- try {
- canvas = document.createElement('canvas'),
+ try {
+ canvas = document.createElement('canvas');
ctx = canvas.getContext('webgl') || canvas.getContext('experimental-webgl');
exts = ctx.getSupportedExtensions();
}
@@ -22,21 +22,21 @@
}
if (ctx === undefined) {
- Modernizr.webgl = new Boolean(false);
+ Modernizr.webgl = new Boolean(false);
}
else {
- Modernizr.webgl = new Boolean(true);
+ Modernizr.webgl = new Boolean(true);
}
-
+
for (var i = -1, len = exts.length; ++i < len; ){
- Modernizr.webgl[exts[i]] = true;
+ Modernizr.webgl[exts[i]] = true;
}
// hack for addressing modernizr testsuite failures. sorry.
if (window.TEST && TEST.audvid){
TEST.audvid.push('webgl');
}
- canvas = undefined;;
+ canvas = undefined;
})();
View
4 feature-detects/workers-blobworkers.js
@@ -9,7 +9,7 @@
try {
// we're avoiding using Modernizr._domPrefixes as the prefix capitalization on
- // these guys are notoriously peculiar.
+ // these guys are notoriously peculiar.
var BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.MSBlobBuilder || window.OBlobBuilder || window.BlobBuilder,
URL = window.MozURL || window.webkitURL || window.MSURL || window.OURL || window.URL;
@@ -18,7 +18,7 @@
bb.append('this.onmessage=function(e){postMessage(e.data)}');
- var url = URL.createObjectURL(bb.getBlob());
+ var url = URL.createObjectURL(bb.getBlob()),
worker = new Worker(url);
bb = null;
View
62 grunt.js
@@ -0,0 +1,62 @@
+/*global module */
+module.exports = function( grunt ) {
+ 'use strict';
+
+ grunt.initConfig({
+ meta: {
+ version: '2.5.3',
+ banner: '/*!\n' +
+ ' * Modernizr v<%= meta.version %>\n' +
+ ' * www.modernizr.com\n *\n' +
+ ' * Copyright (c) Faruk Ates, Paul Irish, Alex Sexton\n' +
+ ' * Available under the BSD and MIT licenses: www.modernizr.com/license/\n */'
+ },
+ lint: {
+ files: [
+ 'grunt.js',
+ 'modernizr.js',
+ 'feature-detects/*.js'
+ ]
+ },
+ min: {
+ dist: {
+ src: [
+ '<banner:meta.banner>',
+ 'modernizr.js'
+ ],
+ dest: 'modernizr.min.js'
+ }
+ },
+ watch: {
+ files: '<config:lint.files>',
+ tasks: 'lint'
+ },
+ jshint: {
+ options: {
+ boss: true,
+ browser: true,
+ curly: false,
+ devel: true,
+ eqeqeq: false,
+ eqnull: true,
+ expr: true,
+ evil: true,
+ immed: false,
+ laxcomma: true,
+ newcap: false,
+ noarg: true,
+ smarttabs: true,
+ sub: true,
+ undef: true
+ },
+ globals: {
+ Modernizr: true,
+ DocumentTouch: true,
+ TEST: true
+ }
+ }
+ });
+
+ grunt.registerTask('default', 'min');
+
+};
View
60 modernizr.js
@@ -216,15 +216,15 @@ window.Modernizr = (function( window, document, undefined ) {
// TODO :: Add flag for hasownprop ? didn't last time
// hasOwnProperty shim by kangax needed for Safari 2.0 support
- _hasOwnProperty = ({}).hasOwnProperty, hasOwnProperty;
+ _hasOwnProperty = ({}).hasOwnProperty, hasOwnProp;
if ( !is(_hasOwnProperty, 'undefined') && !is(_hasOwnProperty.call, 'undefined') ) {
- hasOwnProperty = function (object, property) {
+ hasOwnProp = 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 */
+ 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'));
};
}
@@ -236,26 +236,40 @@ window.Modernizr = (function( window, document, undefined ) {
Function.prototype.bind = function bind(that) {
var target = this;
- if (typeof target != "function") throw new TypeError();
- var
- args = slice.call(arguments, 1),
- bound = function () {
+ if (typeof target != "function") {
+ throw new TypeError();
+ }
- if (this instanceof bound) {
+ var args = slice.call(arguments, 1),
+ bound = function () {
- var F = function(){};
- F.prototype = target.prototype;
- var self = new F();
- var result = target.apply(self, args.concat(slice.call(arguments)));
+ if (this instanceof bound) {
- if (Object(result) === result) return result;
- return self;
+ var F = function(){};
+ F.prototype = target.prototype;
+ var self = new F();
+
+ var result = target.apply(
+ self,
+ args.concat(slice.call(arguments))
+ );
+ if (Object(result) === result) {
+ return result;
+ }
+ return self;
+
+ } else {
+
+ return target.apply(
+ that,
+ args.concat(slice.call(arguments))
+ );
+
+ }
- } else {
- return target.apply( that, args.concat(slice.call(arguments)));
- }
};
+
return bound;
};
}
@@ -523,7 +537,7 @@ window.Modernizr = (function( window, document, undefined ) {
// If the UA supports multiple backgrounds, there should be three occurrences
// of the string "url(" in the return value for elemStyle.background
- return /(url\s*\(.*?){3}/.test(mStyle.background);
+ return (/(url\s*\(.*?){3}/).test(mStyle.background);
};
@@ -568,7 +582,7 @@ window.Modernizr = (function( window, document, undefined ) {
// The non-literal . in this regex is intentional:
// German Chrome returns this value as 0,55
// github.com/Modernizr/Modernizr/issues/#issue/59/comment/516632
- return /^0.55$/.test(mStyle.opacity);
+ return (/^0.55$/).test(mStyle.opacity);
};
@@ -600,9 +614,9 @@ window.Modernizr = (function( window, document, undefined ) {
setCss(
// legacy webkit syntax (FIXME: remove when syntax not in use anymore)
- (str1 + '-webkit- '.split(' ').join(str2 + str1)
+ (str1 + '-webkit- '.split(' ').join(str2 + str1) +
// standard syntax // trailing 'background-image:'
- + prefixes.join(str3 + str1)).slice(0, -str1.length)
+ prefixes.join(str3 + str1)).slice(0, -str1.length)
);
return contains(mStyle.backgroundImage, 'gradient');
@@ -910,7 +924,7 @@ window.Modernizr = (function( window, document, undefined ) {
// Run through all tests and detect their support in the current UA.
// todo: hypothetically we could be doing an array of tests and use a basic loop here.
for ( var feature in tests ) {
- if ( hasOwnProperty(tests, feature) ) {
+ if ( hasOwnProp(tests, feature) ) {
// run the test, throw the return value into the Modernizr,
// then based on that boolean, define an appropriate className
// and push it into an array of classes we'll join later.
@@ -939,7 +953,7 @@ window.Modernizr = (function( window, document, undefined ) {
Modernizr.addTest = function ( feature, test ) {
if ( typeof feature == 'object' ) {
for ( var key in feature ) {
- if ( hasOwnProperty( feature, key ) ) {
+ if ( hasOwnProp( feature, key ) ) {
Modernizr.addTest( key, feature[ key ] );
}
}

0 comments on commit a16c9f7

Please sign in to comment.