andybalholm / cascadia

CSS selector library in Go
BSD 2-Clause "Simplified" License
697 stars 65 forks source link

lt Selector Feature Request #31

Closed tqwewe closed 7 years ago

tqwewe commented 7 years ago

Cascadia doesn't currently support the jQuery lt selector which would be a nice feature to see.

Here is a stack overflow question explaining this feature in detail: http://stackoverflow.com/questions/14005796/jquery-limit-element-query-results


I posted this same issue here on the GoQuery package's issues and was advised to post this issue/feature request here as GoQuery uses cascadia as it's CSS selector.

andybalholm commented 7 years ago

Cascadia, like the CSS spec, only supports selectors which can be expressed as a simple yes/no question about an element. (See the definition of the Selector type: func(*html.Node) bool.) Some jQuery extensions, such as this one, only work relative to a context. (In this case, do we want the first 3 matches in the whole document, or only in a certain subtree?) So implementing them would require a complete rewrite.

I'm not necessarily opposed to adding jQuery extensions. Cascadia already has some of them. But some (like this one) are incompatible with the basic design.

tqwewe commented 7 years ago

Ah okay, I understand. It would just be a handy feature if it were possible to be implemented (without changing the whole package around)