Skip to content

Dealing with arguments #13

Closed
Closed

Description

@davidtheclark

Right now if I parse the selector .foo:nth-child(3) it looks like I'm getting a node whose value is '3' and type is 'tag'.

It seems to me that the parser should differentiate arguments from tags.

But at the same time it probably ought to still report the class .bar in .foo:not(.bar).

What do you think?

Activity

  1. changed the title [-]Dealing with nth-child()[/-] [+]Dealing with arguments[/+] on Jul 11, 2015
  2. ben-eb commented on Jul 11, 2015

    @ben-eb
    Member

    I define tag as a 'fallback' - so that nodes that don't match any of the other patterns (class, id, attribute selector etc) end up in tag. The parser has no knowledge of valid XML/HTML tags. I'm not sure that adding an alias to tag for argument makes sense because what if that value is h1 - doesn't it make more sense as a tag?

  3. davidtheclark commented on Jul 11, 2015

    @davidtheclark
    ContributorAuthor

    Hm. What about this:

    I searched a little through http://www.w3.org/TR/css3-selectors/ and I only see two types of selectors that take arguments, and the type of argument each takes is consistent. The negation pseudo-class, :not(), always takes a simple selector -- so that argument could be parsed just like other selectors. The :nth-*() pseudo-classes (e.g. nth-child(), nth-of-type()) take integers, an + b expressions, and odd and even -- so those could be parsed specially so that their arguments aren't mistaken for type selectors.

    Maybe that way this mistake could be avoided without knowing valid XML/HTML tags.

  4. ben-eb commented on Jul 12, 2015

    @ben-eb
    Member

    I'm not sure if I want to go down the route of parsing different types of pseudo classes as different entities. I wanted to make the parser be aware of CSS-like syntax, so if you made up some new selector like a:unicorns(47) then it could still parse that into a tag, followed by a pseudo containing a tag.

    This seems important because people are generating lots of language extensions; it would be confusing if some pseudo selectors were parsed differently from others.

  5. davidtheclark commented on Jul 12, 2015

    @davidtheclark
    ContributorAuthor

    Ok. I will handle my particular issue in my own code. Thanks.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions