Documentation ¶
Overview ¶
https://drafts.csswg.org/cssom/#common-serializing-idioms
https://www.w3.org/TR/2018/CR-selectors-3-20180130/#w3cselgrammar
Index ¶
- Variables
- func All(s Selector, n *html.Node) []*html.Node
- func EscapeIdentifier(unescaped string) (escaped string)
- func EscapeString(unescaped string) (escaped string)
- func First(s Selector, n *html.Node) *html.Node
- func Unescape(escaped string) (unescaped string)
- type AttributeSelector
- type ChildSelector
- type ClassSelector
- type DescendantSelector
- type ElementSelector
- type IDSelector
- type NextSiblingSelector
- type PseudoFunctionSelector
- type PseudoSelector
- type Selector
- type SelectorSequence
- type SubsequentSiblingSelector
- type UnionSelector
- type UniversalSelector
Constants ¶
This section is empty.
Variables ¶
View Source
var Combinators = map[string]func(Selector, Selector) Selector{ " ": func(s1, s2 Selector) Selector { return &DescendantSelector{s1, s2} }, ">": func(s1, s2 Selector) Selector { return &ChildSelector{s1, s2} }, "+": func(s1, s2 Selector) Selector { return &NextSiblingSelector{s1, s2} }, "~": func(s1, s2 Selector) Selector { return &SubsequentSiblingSelector{s1, s2} }, ",": func(s1, s2 Selector) Selector { return &UnionSelector{s1, s2} }, }
View Source
var Matchers = map[string]func(string, string) bool{ "~=": includeMatch, "|=": func(av, sv string) bool { return av == sv || strings.HasPrefix(av, sv+"-") }, "^=": func(av, sv string) bool { return sv != "" && strings.HasPrefix(av, sv) }, "$=": func(av, sv string) bool { return sv != "" && strings.HasSuffix(av, sv) }, "*=": func(av, sv string) bool { return strings.Contains(av, sv) }, "=": func(av, sv string) bool { return av == sv }, "": func(string, string) bool { return true }, }
View Source
var PseudoClasses = map[string]func(*html.Node) bool{ "root": isRoot, "empty": isEmpty, "checked": func(n *html.Node) bool { return isInput(n) && hasAttribute(n, "checked") }, "disabled": func(n *html.Node) bool { return isInput(n) && hasAttribute(n, "disabled") }, "enabled": func(n *html.Node) bool { return isInput(n) && !hasAttribute(n, "disabled") }, "optional": func(n *html.Node) bool { return isInput(n) && !hasAttribute(n, "required") }, "required": func(n *html.Node) bool { return isInput(n) && hasAttribute(n, "required") }, "read-only": func(n *html.Node) bool { return isInput(n) && hasAttribute(n, "readonly") }, "read-write": func(n *html.Node) bool { return isInput(n) && !hasAttribute(n, "readonly") }, "first-child": nthSiblingCompiled(func(n *html.Node) *html.Node { return n.PrevSibling }, "1", false), "first-of-type": nthSiblingCompiled(func(n *html.Node) *html.Node { return n.PrevSibling }, "1", true), "last-child": nthSiblingCompiled(func(n *html.Node) *html.Node { return n.NextSibling }, "1", false), "last-of-type": nthSiblingCompiled(func(n *html.Node) *html.Node { return n.NextSibling }, "1", true), "only-child": onlyChild(false), "only-of-type": onlyChild(true), }
View Source
var PseudoFunctions = map[string]func(string) (func(*html.Node) bool, error){ "not": nil, "nth-child": nthSibling(func(n *html.Node) *html.Node { return n.PrevSibling }, false), "nth-last-child": nthSibling(func(n *html.Node) *html.Node { return n.NextSibling }, false), "nth-of-type": nthSibling(func(n *html.Node) *html.Node { return n.PrevSibling }, true), "nth-last-of-type": nthSibling(func(n *html.Node) *html.Node { return n.NextSibling }, true), "contains": contains, }
Functions ¶
func EscapeIdentifier ¶
func EscapeString ¶
Types ¶
type AttributeSelector ¶
type AttributeSelector struct { Key string Value string Type string // contains filtered or unexported fields }
func (*AttributeSelector) String ¶
func (s *AttributeSelector) String() string
type ChildSelector ¶
func (*ChildSelector) String ¶
func (s *ChildSelector) String() string
type ClassSelector ¶
type ClassSelector struct{ *AttributeSelector }
func (*ClassSelector) String ¶
func (s *ClassSelector) String() string
type DescendantSelector ¶
func (*DescendantSelector) String ¶
func (s *DescendantSelector) String() string
type ElementSelector ¶
type ElementSelector struct {
Element string
}
func (*ElementSelector) String ¶
func (s *ElementSelector) String() string
type IDSelector ¶
type IDSelector struct{ *AttributeSelector }
func (*IDSelector) String ¶
func (s *IDSelector) String() string
type NextSiblingSelector ¶
func (*NextSiblingSelector) String ¶
func (s *NextSiblingSelector) String() string
type PseudoFunctionSelector ¶
type PseudoFunctionSelector struct { Name string Args string // contains filtered or unexported fields }
func (*PseudoFunctionSelector) String ¶
func (s *PseudoFunctionSelector) String() string
type PseudoSelector ¶
type PseudoSelector struct { Name string // contains filtered or unexported fields }
func (*PseudoSelector) String ¶
func (s *PseudoSelector) String() string
type Selector ¶
func MustCompile ¶
type SelectorSequence ¶
type SelectorSequence struct {
Selectors []Selector
}
func (*SelectorSequence) String ¶
func (s *SelectorSequence) String() string
type SubsequentSiblingSelector ¶
func (*SubsequentSiblingSelector) Match ¶
func (s *SubsequentSiblingSelector) Match(n *html.Node) bool
func (*SubsequentSiblingSelector) String ¶
func (s *SubsequentSiblingSelector) String() string
type UnionSelector ¶
func (*UnionSelector) String ¶
func (s *UnionSelector) String() string
type UniversalSelector ¶
type UniversalSelector struct {
Element string
}
func (*UniversalSelector) String ¶
func (s *UniversalSelector) String() string
Click to show internal directories.
Click to hide internal directories.