css_select/selector

Types

A single attribute-based selector component.

pub type AttributeSelector {
  Id(String)
  Class(String)
  AttributeExists(String)
  AttributeEqual(String, String)
  AttributePrefix(String, String)
  AttributeSuffix(String, String)
  AttributeIncludes(String, String)
  Psuedo(String)
}

Constructors

  • Id(String)

    Matches elements with the given ID attribute.

  • Class(String)

    Matches elements with the given class.

  • AttributeExists(String)

    Matches elements that have the given attribute.

  • AttributeEqual(String, String)

    Matches elements where the attribute equals the given value.

  • AttributePrefix(String, String)

    Matches elements where the attribute value starts with the given prefix.

  • AttributeSuffix(String, String)

    Matches elements where the attribute value ends with the given suffix.

  • AttributeIncludes(String, String)

    Matches elements where the attribute value contains the given substring.

  • Psuedo(String)

    Matches elements with the given pseudo-class.

A complete simple CSS selector, consisting of a tag selector and zero or more attribute selectors.

pub type Selector {
  ElementSelector(TagSelector, List(AttributeSelector))
}

Constructors

The element type part of a selector.

pub type TagSelector {
  Any
  Tag(String)
}

Constructors

  • Any

    Matches any element type.

  • Tag(String)

    Matches elements of the given tag name.

Values

pub fn to_string(selector: Selector) -> String

Convert a Selector back to its CSS selector string representation.

let assert Ok(selector) = css_select.parse_simple_selector("div#foo.bar")
css_select.to_string(selector)
// -> "div#foo.bar"
Search Document