Skip to content

:nth-child, :first-child, etc selecting multiple nodes while used with direct children #39

@cancerberoSgx

Description

@cancerberoSgx

In the code:

 interface I<T=any>{
   m(i: number, g: (aParameter1: number)=>void)
}

I expect that InterfaceDeclaration > :nth-child(1) to match only one node (since any node cannot have more than one child that is the first one) but is matching 3 nodes. The same happens with all :first-child, :last-child, etc.

Another example, in the code:

function f(){
  var a = 1
  function g(){var a=1}
}

This selector SourceFile>FunctionDeclaration:has([name="f"])>Block>*>*>*>*>VariableDeclaration matches only one child as expected, but this one (just replace VariableDeclaration with :first-child) matches 2 nodes.

It's like whenever you use :first-child or cia, the previous '>' (direct child ) is not taking in account and replaced by " " (ancestor)

I would like to know if this is the expected behavior and if not if you would accept a PR for this (supposing is simple to fix) ?

Thanks, keep it up!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions