Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd feature detect for nth-child() #685
Conversation
| 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++) { |
This comment has been minimized.
This comment has been minimized.
| // nth-child pseudo selector | ||
| Modernizr.addTest('nthchild', function(){ | ||
|
|
||
| return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) { |
This comment has been minimized.
This comment has been minimized.
|
|
||
| return Modernizr.testStyles("#modernizr div {width:1px} #modernizr div:nth-child(2n) {width:2px;}", function (elem) { | ||
| var elems = elem.getElementsByTagName("div"), | ||
| test = true; |
This comment has been minimized.
This comment has been minimized.
|
Please add a description to the PR about how the test works. |
| var elems = elem.getElementsByTagName('div'), | ||
| test = true; | ||
|
|
||
| for (var i=0; i<5; i++) { |
This comment has been minimized.
This comment has been minimized.
| test = true; | ||
|
|
||
| for (var i=0; i<5; i++) { | ||
| test = test && elems[i].offsetWidth == i%2+1; |
This comment has been minimized.
This comment has been minimized.
| @@ -0,0 +1,15 @@ | |||
| // nth-child pseudo selector | |||
| Modernizr.addTest('nthchild', function(){ | |||
This comment has been minimized.
This comment has been minimized.
|
@emilchristensen ping |
alexslade
commented
Feb 14, 2013
|
|
bradgreens
commented
Jun 25, 2013
|
+1 |
|
This needs updating to the v3 format before we can accept it. @emilchristensen are you able to do this, or does someone else fancy volunteering? |
|
I'll update it to v3 asap |
|
Great, thanks. |
|
Alright, this is updated and should adhere to the v3 principle and former comments in this thread. |
|
Need me to squash it before merge or are we good to go? |
- Moved 'how it works' out of DOC block (this is for user documentation, rather than maintainer/implementation documentation – I've also clarified this on [the wiki](https://github.com/Modernizr/Modernizr/wiki/Authoring-a-v3-test)) - Turned `"authors"` and `"warnings"` fields into arrays - Corrected `"property"` field to match name used in `Modernizr.addTest()` (these must be the same)
|
Thanks. I've raised a PR on your fork of the repo with a couple of changes to the metadata/DOC blocks. If you're happy with that, could you merge that in, squash the commits and push again? Then we'll pull it in. Thanks :-) |
|
I couldn't rebase n' squash all the way back I'm afraid. I'm guessing too big difference in the structure of how the project looked back then. I've been able to squash back to 1fe1e83. Do you want me to push that? Or do you have an idea on how to fix the problems (I'm thinking it's something with the files getting added in different places) |
|
Yeah if you could push that, that'll be fine – thanks. |
Add feature detect for nth-child()
|
Nice one, thanks @emilchristensen! |
Add feature detect for nth-child()
emilchristensen commentedSep 7, 2012
Reference: http://reference.sitepoint.com/css/pseudoclass-nthchild
Tested to work in:
Internet Explorer 7 (false), 8 (false), 9 (true)
Chrome 7 (true), 21 (true)
Firefox 3.6 (true), 14 (true)
Safari 5.2 (true), 6 (true)
Opera 9.0 build 3447 (false), 12 (true)
Known issues in:
Safari 3.1, 3.2.2 (false negatives)