Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add feature detect for nth-child() #685

Merged
merged 18 commits into from Jul 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 13 additions & 8 deletions Gruntfile.js
Expand Up @@ -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({
Expand Down Expand Up @@ -183,15 +185,18 @@ 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').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() {
Expand Down
1 change: 1 addition & 0 deletions feature-detects/css/gradients.js
Expand Up @@ -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/"
Expand Down
43 changes: 43 additions & 0 deletions 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 `<div>` elements with `1px` width are created.
// Then every other element has its `width` set to `2px`.
// A Javascript loop then tests if the `<div>`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);
});
3 changes: 2 additions & 1 deletion lib/cli.js
Expand Up @@ -4,5 +4,6 @@
var grunt = require("grunt");

module.exports = {
build: require("./build")
build: require("./build"),
metadata: require("./generate-meta")
};
7 changes: 5 additions & 2 deletions package.json
Expand Up @@ -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"
},
Expand Down