-
Notifications
You must be signed in to change notification settings - Fork 136
Parse nth-child(-/*comment*/n+b) #154
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a bit confused, the patch in bug 1364009 reads:
Don't allow comments/spaces between signs,numbers,and `n` in an+b syntax for nth-child;
But it seems it's allowing comments but not spaces, right?
src/nth.rs
Outdated
"n" => parse_b(input, 1), | ||
"n-" => parse_signless_b(input, 1, -1), | ||
_ => Ok((1, try!(parse_n_dash_digits(&*value)))) | ||
Token::Delim('+')| Token::Delim('-') => match try!(input.next_including_whitespace()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: spacing.
But I'd write it as:
Token::Delim(delim) => {
let val = match delim {
'+' => 1,
'-' => -1,
_ => return Err(()),
};
match try!(input.next_including_whitespace()) {
// ...
}
}
That way you avoid the extra variable at the top too.
Yeah, so the spec is weird here. It explicitly includes a specification for all kinds of tokens, including tokens like On top of that, the Yes, that probably could be clarified more in that commit message but it's long :) I will try. In this cssparser PR, i don't really change much behavior, I just make -n behave the the same as +n, which should match up regardless of your interpretation of the rest. |
949ba19
to
90ede21
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, fair enough.
The fix seems legit (feels weird to treat +
differently than -
here), and as long as it matches other browsers...
r=me
Let's wait until the discussion in #153 settles though. |
r=me if w3c/csswg-drafts#1498 is accepted. (I’m officially co-editor of that spec so I could accept that change, but this section is tricky and Tab wrote it so I’d rather have him do it.) |
👎, this appears to be a total misreading of the Syntax spec. More details in w3c/csswg-drafts#1498 |
This means that these tests only require Firefox fixes to pass now. |
fixes #153
r? @emilio
This change is