mirror of
https://github.com/ericchiang/pup
synced 2025-01-30 17:41:39 +00:00
added support for -n+A for :nth-child
This commit is contained in:
parent
681d7bb639
commit
8bef3ef15b
12
selector.go
12
selector.go
@ -524,8 +524,18 @@ func parseNthPseudo(cmd string) (PseudoClass, error) {
|
|||||||
return n.Type == html.ElementNode && countNth(n)%cycle == offset
|
return n.Type == html.ElementNode && countNth(n)%cycle == offset
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
r = regexp.MustCompile(`^-n[ ]?\+[ ]?([0-9])`)
|
||||||
|
subMatch = r.FindAllStringSubmatch(number, -1)
|
||||||
|
if len(subMatch) == 1 && len(subMatch[0]) == 2 {
|
||||||
|
offset, _ := strconv.Atoi(subMatch[0][1])
|
||||||
|
return func(n *html.Node) bool {
|
||||||
|
return n.Type == html.ElementNode && countNth(n) <= offset
|
||||||
|
}, nil
|
||||||
|
}
|
||||||
|
|
||||||
// check against 'n+2' pattern
|
// check against 'n+2' pattern
|
||||||
r = regexp.MustCompile(`n[ ]?\+[ ]?([0-9])`)
|
r = regexp.MustCompile(`^n[ ]?\+[ ]?([0-9])`)
|
||||||
subMatch = r.FindAllStringSubmatch(number, -1)
|
subMatch = r.FindAllStringSubmatch(number, -1)
|
||||||
if len(subMatch) == 1 && len(subMatch[0]) == 2 {
|
if len(subMatch) == 1 && len(subMatch[0]) == 2 {
|
||||||
offset, _ := strconv.Atoi(subMatch[0][1])
|
offset, _ := strconv.Atoi(subMatch[0][1])
|
||||||
|
Loading…
Reference in New Issue
Block a user