PureHTML.Query.Selector (PureHTML v0.4.0)

View Source

Represents a parsed CSS selector and provides matching functionality.

Summary

Functions

Checks if a node matches this selector.

Types

t()

@type t() :: %PureHTML.Query.Selector{
  attributes: [PureHTML.Query.Selector.AttributeSelector.t()],
  classes: [String.t()],
  id: String.t() | nil,
  type: String.t() | nil
}

Functions

match?(node, selector)

@spec match?(term(), t()) :: boolean()

Checks if a node matches this selector.

Examples

iex> selector = %PureHTML.Query.Selector{type: "div"}
iex> PureHTML.Query.Selector.match?({"div", [], []}, selector)
true

iex> selector = %PureHTML.Query.Selector{type: "div"}
iex> PureHTML.Query.Selector.match?({"p", [], []}, selector)
false