Documentation ¶
Overview ¶
Package cascadia is an implementation of CSS selectors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Matcher ¶ added in v1.1.0
Matcher is the interface for basic selector functionality. Match returns whether a selector matches n.
type Sel ¶ added in v1.1.0
type Sel interface { Matcher Specificity() Specificity // Returns a CSS input compiling to this selector. String() string // Returns a pseudo-element, or an empty string. PseudoElement() string }
Sel is the interface for all the functionality provided by selectors.
func Parse ¶ added in v1.1.0
Parse parses a selector. Use `ParseWithPseudoElement` if you need support for pseudo-elements.
func ParseWithPseudoElement ¶ added in v1.2.0
ParseWithPseudoElement parses a single selector, with support for pseudo-element.
type Selector ¶
A Selector is a function which tells whether a node matches or not.
This type is maintained for compatibility; I recommend using the newer and more idiomatic interfaces Sel and Matcher.
func Compile ¶
Compile parses a selector and returns, if successful, a Selector object that can be used to match against html.Node objects.
func MustCompile ¶
MustCompile is like Compile, but panics instead of returning an error.
type SelectorGroup ¶ added in v1.1.0
type SelectorGroup []Sel
A SelectorGroup is a list of selectors, which matches if any of the individual selectors matches.
func ParseGroup ¶ added in v1.1.0
func ParseGroup(sel string) (SelectorGroup, error)
ParseGroup parses a selector, or a group of selectors separated by commas. Use `ParseGroupWithPseudoElements` if you need support for pseudo-elements.
func ParseGroupWithPseudoElements ¶ added in v1.2.0
func ParseGroupWithPseudoElements(sel string) (SelectorGroup, error)
ParseGroupWithPseudoElements parses a selector, or a group of selectors separated by commas. It supports pseudo-elements.
func (SelectorGroup) Match ¶ added in v1.1.0
func (s SelectorGroup) Match(n *html.Node) bool
Match returns true if the node matches one of the single selectors.
func (SelectorGroup) String ¶ added in v1.2.0
func (c SelectorGroup) String() string
type Specificity ¶ added in v1.1.0
type Specificity [3]int
Specificity is the CSS specificity as defined in https://www.w3.org/TR/selectors/#specificity-rules with the convention Specificity = [A,B,C].
func (Specificity) Add ¶ added in v1.1.0
func (s Specificity) Add(other Specificity) Specificity
func (Specificity) Less ¶ added in v1.1.0
func (s Specificity) Less(other Specificity) bool
returns `true` if s < other (strictly), false otherwise