From d1e9adda21744b12cc74da1e7a3652a4a7c0aca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Thu, 6 Sep 2012 16:30:13 +0200 Subject: [PATCH 01/13] Add nth-child feature-detect --- feature-detects/css-nthchild.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 feature-detects/css-nthchild.js diff --git a/feature-detects/css-nthchild.js b/feature-detects/css-nthchild.js new file mode 100644 index 0000000000..59223cd3fc --- /dev/null +++ b/feature-detects/css-nthchild.js @@ -0,0 +1,13 @@ +// nth-child pseudo selector +Modernizr.addTest('nthchild', function(){ + + return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) { + var elems = elem.getElementsByTagName("div"), + test = true; + for (i=0; i<5; i++) { + test = test && elems[i].offsetWidth == i%2+1; + } + return test; + }, 5); + +}); \ No newline at end of file From 3b7f28f66875cd41dfd546764c23d5cf567285d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Fri, 7 Sep 2012 11:35:50 +0300 Subject: [PATCH 02/13] Fix indent, single-quotes and leaking i --- feature-detects/css-nthchild.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/feature-detects/css-nthchild.js b/feature-detects/css-nthchild.js index 59223cd3fc..5582259f5c 100644 --- a/feature-detects/css-nthchild.js +++ b/feature-detects/css-nthchild.js @@ -1,13 +1,15 @@ // nth-child pseudo selector Modernizr.addTest('nthchild', function(){ - return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) { - var elems = elem.getElementsByTagName("div"), - test = true; - for (i=0; i<5; i++) { - test = test && elems[i].offsetWidth == i%2+1; - } - return test; - }, 5); + return Modernizr.testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function (elem) { + var elems = elem.getElementsByTagName('div'), + test = true; -}); \ No newline at end of file + for (var i=0; i<5; i++) { + test = test && elems[i].offsetWidth == i%2+1; + } + + return test; + }, 5); + +}); From cb03dbf8f5b479308f52f23d41843db611155bb9 Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Thu, 13 Jun 2013 10:35:02 -0700 Subject: [PATCH 03/13] Use "matchdep" to avoid requiring dev dependencies. --- Gruntfile.js | 9 +-------- package.json | 7 +++++-- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 9033b5e778..1efef8f84c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -184,14 +184,7 @@ module.exports = function( grunt ) { } }); // Load required contrib packages - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-qunit'); - grunt.loadNpmTasks('grunt-contrib-nodeunit'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-clean'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-requirejs'); + require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks); // Strip define fn grunt.registerMultiTask('stripdefine', "Strip define call from dist file", function() { diff --git a/package.json b/package.json index a5741dcade..490ad4e215 100644 --- a/package.json +++ b/package.json @@ -12,16 +12,19 @@ "requirejs": "~2.1.4", "underscore": "~1.4.4", "marked": "~0.2.8", + "matchdep": "~0.1.2", "grunt": "~0.4.0", "grunt-contrib-jshint": "~0.3.0", "grunt-contrib-uglify": "~0.2.0", "grunt-contrib-watch": "~0.3.1", "grunt-contrib-clean": "~0.4.0", "grunt-contrib-copy": "~0.4.0", - "grunt-contrib-qunit": "~0.2.0", - "grunt-contrib-nodeunit": "~0.2.0", "grunt-contrib-requirejs": "~0.4.0" }, + "devDependencies": { + "grunt-contrib-qunit": "~0.2.0", + "grunt-contrib-nodeunit": "~0.2.0" + }, "scripts": { "test": "grunt test" }, From 7a7e4cc6c225c1f611553ffe74b915a905f496c6 Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Thu, 13 Jun 2013 10:48:39 -0700 Subject: [PATCH 04/13] Add metadata to CLI. --- lib/cli.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/cli.js b/lib/cli.js index 632679af27..ab44868ede 100644 --- a/lib/cli.js +++ b/lib/cli.js @@ -4,5 +4,6 @@ var grunt = require("grunt"); module.exports = { - build: require("./build") + build: require("./build"), + metadata: require("./generate-meta") }; From ddff156911b85ce559d35c9bf37dd07f3733627b Mon Sep 17 00:00:00 2001 From: Richard Herrera Date: Thu, 13 Jun 2013 11:07:30 -0700 Subject: [PATCH 05/13] Use matchdep to detect if devDependencies are installed. Require each if so. --- Gruntfile.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Gruntfile.js b/Gruntfile.js index 1efef8f84c..4d1774f802 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -3,6 +3,8 @@ module.exports = function( grunt ) { 'use strict'; + var fs = require('fs'); + var path = require('path'); var modConfig = grunt.file.readJSON('lib/config-all.json'); grunt.initConfig({ @@ -183,8 +185,18 @@ module.exports = function( grunt ) { } } }); + // Load required contrib packages - require('matchdep').filterAll('grunt-*').forEach(grunt.loadNpmTasks); + require('matchdep').filter('grunt-*').forEach(grunt.loadNpmTasks); + + // devDependencies may or may not be installed + require('matchdep').filterDev('grunt-*').forEach(function (contrib) { + module.paths.forEach(function (dir) { + if (fs.existsSync(path.join(dir, contrib))) { + grunt.loadNpmTasks(contrib); + } + }); + }); // Strip define fn grunt.registerMultiTask('stripdefine', "Strip define call from dist file", function() { From dfb4cff564dabcdb65b5957b235c3fa3e5b164eb Mon Sep 17 00:00:00 2001 From: Stu Cox Date: Tue, 18 Jun 2013 17:35:45 +0100 Subject: [PATCH 06/13] Added note to `cssgradients` test re. false positive in webOS (fixes #202) --- feature-detects/css/gradients.js | 1 + 1 file changed, 1 insertion(+) diff --git a/feature-detects/css/gradients.js b/feature-detects/css/gradients.js index 8f2ed962de..c3af350a2e 100644 --- a/feature-detects/css/gradients.js +++ b/feature-detects/css/gradients.js @@ -4,6 +4,7 @@ "caniuse": "css-gradients", "property": "cssgradients", "tags": ["css"], + "knownBugs": ["False-positives on webOS (https://github.com/Modernizr/Modernizr/issues/202)"], "notes": [{ "name": "Webkit Gradient Syntax", "href": "http://webkit.org/blog/175/introducing-css-gradients/" From c5f2bf0a20fb40d24c51ea095c509bb6db5bf76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Thu, 6 Sep 2012 16:30:13 +0200 Subject: [PATCH 07/13] Add nth-child feature-detect --- feature-detects/css-nthchild.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 feature-detects/css-nthchild.js diff --git a/feature-detects/css-nthchild.js b/feature-detects/css-nthchild.js new file mode 100644 index 0000000000..59223cd3fc --- /dev/null +++ b/feature-detects/css-nthchild.js @@ -0,0 +1,13 @@ +// nth-child pseudo selector +Modernizr.addTest('nthchild', function(){ + + return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) { + var elems = elem.getElementsByTagName("div"), + test = true; + for (i=0; i<5; i++) { + test = test && elems[i].offsetWidth == i%2+1; + } + return test; + }, 5); + +}); \ No newline at end of file From c9645f1d6e5c8b6af4709c46c31a11792e87bfc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Fri, 7 Sep 2012 11:35:50 +0300 Subject: [PATCH 08/13] Fix indent, single-quotes and leaking i --- feature-detects/css-nthchild.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/feature-detects/css-nthchild.js b/feature-detects/css-nthchild.js index 59223cd3fc..5582259f5c 100644 --- a/feature-detects/css-nthchild.js +++ b/feature-detects/css-nthchild.js @@ -1,13 +1,15 @@ // nth-child pseudo selector Modernizr.addTest('nthchild', function(){ - return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) { - var elems = elem.getElementsByTagName("div"), - test = true; - for (i=0; i<5; i++) { - test = test && elems[i].offsetWidth == i%2+1; - } - return test; - }, 5); + return Modernizr.testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function (elem) { + var elems = elem.getElementsByTagName('div'), + test = true; -}); \ No newline at end of file + for (var i=0; i<5; i++) { + test = test && elems[i].offsetWidth == i%2+1; + } + + return test; + }, 5); + +}); From 1fe1e8388494599536d7bbe0164e6f5f46cb0d3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Fri, 28 Jun 2013 10:54:47 +0200 Subject: [PATCH 09/13] Move and rename file to new structure. Rewrite test to use Modernizr v3 AMD structure --- feature-detects/css-nthchild.js | 15 --------------- feature-detects/css/nthchild.js | 34 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 15 deletions(-) delete mode 100644 feature-detects/css-nthchild.js create mode 100644 feature-detects/css/nthchild.js diff --git a/feature-detects/css-nthchild.js b/feature-detects/css-nthchild.js deleted file mode 100644 index 5582259f5c..0000000000 --- a/feature-detects/css-nthchild.js +++ /dev/null @@ -1,15 +0,0 @@ -// nth-child pseudo selector -Modernizr.addTest('nthchild', function(){ - - return Modernizr.testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function (elem) { - var elems = elem.getElementsByTagName('div'), - test = true; - - for (var i=0; i<5; i++) { - test = test && elems[i].offsetWidth == i%2+1; - } - - return test; - }, 5); - -}); diff --git a/feature-detects/css/nthchild.js b/feature-detects/css/nthchild.js new file mode 100644 index 0000000000..ebde0de355 --- /dev/null +++ b/feature-detects/css/nthchild.js @@ -0,0 +1,34 @@ +/*! +{ + "name": "CSS :nth-child pseudo-selector", + "caniuse": "css-sel3", + "property": "nth-child", + "tags": ["css"], + "notes": [ + { + "name": "Related Github Issue", + "href": "https://github.com/Modernizr/Modernizr/pull/685" + }, + { + "name": "Sitepoint :nth-child documentation", + "href": "http://reference.sitepoint.com/css/pseudoclass-nthchild" + } + ], + "authors": "@emilchristensen", + "warnings": "Known false negative in Safari 3.1 and Safari 3.2.2" +} +!*/ +define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { + testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function( elem ) { + Modernizr.addTest('nthchild', function () { + var elems = elem.getElementsByTagName('div'), + test = true; + + for (var i = 0; i < 5; i++) { + test = test && elems[i].offsetWidth === i % 2 + 1; + } + + return test; + }); + }, 5); +}); From e1036297da979593c6e03b843cac6178ab2de35e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Fri, 28 Jun 2013 11:06:24 +0200 Subject: [PATCH 10/13] Added DOC block with description of how the test works --- feature-detects/css/nthchild.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/feature-detects/css/nthchild.js b/feature-detects/css/nthchild.js index ebde0de355..a5b2030ec8 100644 --- a/feature-detects/css/nthchild.js +++ b/feature-detects/css/nthchild.js @@ -18,6 +18,14 @@ "warnings": "Known false negative in Safari 3.1 and Safari 3.2.2" } !*/ +/* DOC + +## Detects support for the ':nth-child()' css pseudo-selector. + +###How it works +5 `
` elements with `1px` width is created. Then every other element has its `width` set to `2px`. A Javascript lopp then tests if the `
`'s has the expected width using the modulus operator. + +*/ define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function( elem ) { Modernizr.addTest('nthchild', function () { From 4b68b43fbbcf5dcbff0220900e262746b0d92d65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Fri, 28 Jun 2013 11:09:31 +0200 Subject: [PATCH 11/13] Fixed @sindresorhus' line comment about spacing concerning anonymous functions --- feature-detects/css/nthchild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/feature-detects/css/nthchild.js b/feature-detects/css/nthchild.js index a5b2030ec8..9e70f077fa 100644 --- a/feature-detects/css/nthchild.js +++ b/feature-detects/css/nthchild.js @@ -28,7 +28,7 @@ */ define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function( elem ) { - Modernizr.addTest('nthchild', function () { + Modernizr.addTest('nthchild', function() { var elems = elem.getElementsByTagName('div'), test = true; From 122f5beab232242935e48e906c56e6bf21ec5aa9 Mon Sep 17 00:00:00 2001 From: Stu Cox Date: Mon, 1 Jul 2013 14:00:55 +0100 Subject: [PATCH 12/13] =?UTF-8?q?Metadata=20/=20DOC=20improvements:=20-=20?= =?UTF-8?q?Moved=20'how=20it=20works'=20out=20of=20DOC=20block=20(this=20i?= =?UTF-8?q?s=20for=20user=20documentation,=20rather=20than=20maintainer/im?= =?UTF-8?q?plementation=20documentation=20=E2=80=93=20I've=20also=20clarif?= =?UTF-8?q?ied=20this=20on=20[the=20wiki](https://github.com/Modernizr/Mod?= =?UTF-8?q?ernizr/wiki/Authoring-a-v3-test))=20-=20Turned=20`"authors"`=20?= =?UTF-8?q?and=20`"warnings"`=20fields=20into=20arrays=20-=20Corrected=20`?= =?UTF-8?q?"property"`=20field=20to=20match=20name=20used=20in=20`Moderniz?= =?UTF-8?q?r.addTest()`=20(these=20must=20be=20the=20same)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- feature-detects/css/nthchild.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/feature-detects/css/nthchild.js b/feature-detects/css/nthchild.js index 9e70f077fa..c2befee9da 100644 --- a/feature-detects/css/nthchild.js +++ b/feature-detects/css/nthchild.js @@ -2,7 +2,7 @@ { "name": "CSS :nth-child pseudo-selector", "caniuse": "css-sel3", - "property": "nth-child", + "property": "nthchild", "tags": ["css"], "notes": [ { @@ -14,19 +14,20 @@ "href": "http://reference.sitepoint.com/css/pseudoclass-nthchild" } ], - "authors": "@emilchristensen", - "warnings": "Known false negative in Safari 3.1 and Safari 3.2.2" + "authors": ["@emilchristensen"], + "warnings": ["Known false negative in Safari 3.1 and Safari 3.2.2"] } !*/ /* DOC -## Detects support for the ':nth-child()' css pseudo-selector. - -###How it works -5 `
` elements with `1px` width is created. Then every other element has its `width` set to `2px`. A Javascript lopp then tests if the `
`'s has the expected width using the modulus operator. +Detects support for the ':nth-child()' CSS pseudo-selector. */ define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { + // 5 `
` elements with `1px` width are created. + // Then every other element has its `width` set to `2px`. + // A Javascript loop then tests if the `
`s have the expected width + // using the modulus operator. testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function( elem ) { Modernizr.addTest('nthchild', function() { var elems = elem.getElementsByTagName('div'), @@ -35,7 +36,7 @@ define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { for (var i = 0; i < 5; i++) { test = test && elems[i].offsetWidth === i % 2 + 1; } - + return test; }); }, 5); From b61e97d73b46abc504054414fc6adf6b2189f4d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emil=20R=C3=B8mer=20Christensen?= Date: Fri, 28 Jun 2013 10:54:47 +0200 Subject: [PATCH 13/13] Add nth-child feature-detect --- feature-detects/css-nthchild.js | 15 ------------ feature-detects/css/nthchild.js | 43 +++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 15 deletions(-) delete mode 100644 feature-detects/css-nthchild.js create mode 100644 feature-detects/css/nthchild.js diff --git a/feature-detects/css-nthchild.js b/feature-detects/css-nthchild.js deleted file mode 100644 index 5582259f5c..0000000000 --- a/feature-detects/css-nthchild.js +++ /dev/null @@ -1,15 +0,0 @@ -// nth-child pseudo selector -Modernizr.addTest('nthchild', function(){ - - return Modernizr.testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function (elem) { - var elems = elem.getElementsByTagName('div'), - test = true; - - for (var i=0; i<5; i++) { - test = test && elems[i].offsetWidth == i%2+1; - } - - return test; - }, 5); - -}); diff --git a/feature-detects/css/nthchild.js b/feature-detects/css/nthchild.js new file mode 100644 index 0000000000..c2befee9da --- /dev/null +++ b/feature-detects/css/nthchild.js @@ -0,0 +1,43 @@ +/*! +{ + "name": "CSS :nth-child pseudo-selector", + "caniuse": "css-sel3", + "property": "nthchild", + "tags": ["css"], + "notes": [ + { + "name": "Related Github Issue", + "href": "https://github.com/Modernizr/Modernizr/pull/685" + }, + { + "name": "Sitepoint :nth-child documentation", + "href": "http://reference.sitepoint.com/css/pseudoclass-nthchild" + } + ], + "authors": ["@emilchristensen"], + "warnings": ["Known false negative in Safari 3.1 and Safari 3.2.2"] +} +!*/ +/* DOC + +Detects support for the ':nth-child()' CSS pseudo-selector. + +*/ +define(['Modernizr', 'testStyles'], function( Modernizr, testStyles ) { + // 5 `
` elements with `1px` width are created. + // Then every other element has its `width` set to `2px`. + // A Javascript loop then tests if the `
`s have the expected width + // using the modulus operator. + testStyles('#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}', function( elem ) { + Modernizr.addTest('nthchild', function() { + var elems = elem.getElementsByTagName('div'), + test = true; + + for (var i = 0; i < 5; i++) { + test = test && elems[i].offsetWidth === i % 2 + 1; + } + + return test; + }); + }, 5); +});