Skip to content

Loading…

Update master #631

Merged
merged 1 commit into from

4 participants

@urazkines

Better CSS first-child detect.

@paulirish paulirish commented on the diff
feature-detects/css-lastchild.js
@@ -2,6 +2,7 @@
// https://github.com/Modernizr/Modernizr/pull/304
-Modernizr.testStyles("#modernizr div {width:100px} #modernizr :last-child{width:200px;display:block}", function(elem) {
- return elem.lastChild.offsetWidth > elem.firstChild.offsetWidth;
-}, 1);
+Modernizr.testStyles("#modernizr div {width:100px} #modernizr :last-child{width:200px;display:block}", function (elem) {
+ var lastchild = Modernizr.addTest('lastchild', elem.lastChild.offsetWidth > elem.firstChild.offsetWidth);
@paulirish Modernizr member

why assign to the var at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@paulirish paulirish commented on the diff
feature-detects/css-lastchild.js
@@ -2,6 +2,7 @@
// https://github.com/Modernizr/Modernizr/pull/304
-Modernizr.testStyles("#modernizr div {width:100px} #modernizr :last-child{width:200px;display:block}", function(elem) {
- return elem.lastChild.offsetWidth > elem.firstChild.offsetWidth;
-}, 1);
+Modernizr.testStyles("#modernizr div {width:100px} #modernizr :last-child{width:200px;display:block}", function (elem) {
+ var lastchild = Modernizr.addTest('lastchild', elem.lastChild.offsetWidth > elem.firstChild.offsetWidth);
+}, 2);
@paulirish Modernizr member

pretty sure we dont need the 2.
cc @ryanseddon

otherwise this looks good. thanks!

@ryanseddon Modernizr member

In the original pull request, #304, it was set to 1 because of the weird behaviour in safari 3 and down. So I assume it needs to be there for that reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@ryanseddon
Modernizr member

I think for consistency the addTest method should be the parent around any other method calls. Unless you do this for a reason?

@iboozyvoozy

ios safari

@paulirish
Modernizr member

pulling. and i'm going to fix this up after.

@paulirish paulirish merged commit 34df7a3 into Modernizr:master
@paulirish paulirish added a commit that referenced this pull request
@paulirish paulirish fixup lastchild syntax. fixes #631 45bdc31
@phistuck phistuck pushed a commit that referenced this pull request
PhistucK fixup lastchild syntax. fixes #631 8da1728
@patrickkettner patrickkettner pushed a commit to patrickkettner/Modernizr that referenced this pull request
@paulirish paulirish fixup lastchild syntax. fixes #631 3281486
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 12, 2012
  1. @urazkines

    Update master

    urazkines committed
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 3 deletions.
  1. +4 −3 feature-detects/css-lastchild.js
View
7 feature-detects/css-lastchild.js
@@ -2,6 +2,7 @@
// https://github.com/Modernizr/Modernizr/pull/304
-Modernizr.testStyles("#modernizr div {width:100px} #modernizr :last-child{width:200px;display:block}", function(elem) {
- return elem.lastChild.offsetWidth > elem.firstChild.offsetWidth;
-}, 1);
+Modernizr.testStyles("#modernizr div {width:100px} #modernizr :last-child{width:200px;display:block}", function (elem) {
+ var lastchild = Modernizr.addTest('lastchild', elem.lastChild.offsetWidth > elem.firstChild.offsetWidth);
@paulirish Modernizr member

why assign to the var at all?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+}, 2);
@paulirish Modernizr member

pretty sure we dont need the 2.
cc @ryanseddon

otherwise this looks good. thanks!

@ryanseddon Modernizr member

In the original pull request, #304, it was set to 1 because of the weird behaviour in safari 3 and down. So I assume it needs to be there for that reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+
Something went wrong with that request. Please try again.