README

mizchi/crater-css/selector does not have a README file

#
Attribute

pub(all) struct Attribute {
name : String
value : String
}

Attribute value on an element

#
AttributeMatch

pub enum AttributeMatch {
Exists
Exact(String)
Includes(String)
DashMatch(String)
Prefix(String)
Suffix(String)
Substring(String)
}

Attribute matching mode

#
AttributeSelector

pub struct AttributeSelector {
name : String
match_type : AttributeMatch
case_insensitive : Bool
}

Attribute selector

#
Combinator

pub enum Combinator {
Descendant
Child
NextSibling
SubsequentSibling
}

Combinator between compound selectors
impl Show for Combinator

#
ComplexSelector

pub struct ComplexSelector {
head : CompoundSelector
tail : Array[ComplexSelectorStep]
}

Complex selector - compound selectors joined by combinators e.g., div > p.intro + span

#
ComplexSelector::simple

Create a complex selector from a single compound

#
ComplexSelectorStep

pub struct ComplexSelectorStep {
combinator : Combinator
selector : CompoundSelector
}

A step in a complex selector: combinator + compound selector

#
CompoundSelector

pub struct CompoundSelector {
type_selector : SimpleSelector?
subclasses : Array[SimpleSelector]
}

Compound selector - a sequence of simple selectors without combinator e.g., div.foo#bar:hover

#
CompoundSelector::from_class

fn CompoundSelector::from_class(class_name : String) -> CompoundSelector

Create a simple compound selector with just a class selector

#
CompoundSelector::from_id

fn CompoundSelector::from_id(id : String) -> CompoundSelector

Create a simple compound selector with just an ID selector

#
CompoundSelector::from_type

fn CompoundSelector::from_type(tag_name : String) -> CompoundSelector

Create a simple compound selector with just a type selector

#
CompoundSelector::universal

Create a simple compound selector with universal selector

#
Element

pub(all) struct Element {
tag_name : String
id : String?
classes : Array[String]
attributes : Array[Attribute]
custom_states : Array[String]
parent : Element?
prev_sibling : Element?
next_sibling : Element?
children : Array[Element]
sibling_index : Int
sibling_count : Int
}

Element data for selector matching This is a concrete type that can be used with or without a real DOM

#
Element::add_class

fn Element::add_class(self : Element, class_name : String) -> Element

#
Element::add_custom_state

fn Element::add_custom_state(self : Element, state : String) -> Element

#
Element::get_attribute

fn Element::get_attribute(self : Element, name : String) -> String?

Get attribute value by name

#
Element::has_class

fn Element::has_class(self : Element, class_name : String) -> Bool

Check if element has a specific class

#
Element::is_first_child

fn Element::is_first_child(self : Element) -> Bool

Check if element is first child

#
Element::is_last_child

fn Element::is_last_child(self : Element) -> Bool

Check if element is last child

#
Element::new

fn Element::new(tag_name : String) -> Element

Create a new element with minimal information

#
Element::set_attribute

fn Element::set_attribute(self : Element, name : String, value : String) -> Element

#
Element::set_id

fn Element::set_id(self : Element, id : String) -> Element

Builder for creating elements with fluent API

#
Element::set_parent

fn Element::set_parent(self : Element, parent : Element) -> Element

#
Element::set_sibling_info

fn Element::set_sibling_info(self : Element, index : Int, count : Int) -> Element

#
Element::with_classes

fn Element::with_classes(tag_name : String, classes : Array[String]) -> Element

Create an element with classes

#
Element::with_id

fn Element::with_id(tag_name : String, id : String) -> Element

Create an element with id

#
ForcedPseudoStates

pub(all) struct ForcedPseudoStates {
hover : Bool
focus : Bool
active : Bool
focus_visible : Bool
focus_within : Bool
} derive(Eq,
Debug
)

#
ForcedPseudoStates::is_empty

fn ForcedPseudoStates::is_empty(self : ForcedPseudoStates) -> Bool

#
ForcedPseudoStates::none

#
NthExpr

pub struct NthExpr {
a : Int
b : Int
}

Nth expression: An+B
impl Show for NthExpr

#
PseudoClass

pub enum PseudoClass {
FirstChild
LastChild
OnlyChild
NthChild(NthExpr)
NthLastChild(NthExpr)
FirstOfType
LastOfType
OnlyOfType
NthOfType(NthExpr)
NthLastOfType(NthExpr)
Root
Empty
Not(Array[CompoundSelector])
Is(Array[ComplexSelector])
Where(Array[ComplexSelector])
Has(Array[RelativeSelector])
State(String)
Hover
Active
Focus
FocusVisible
FocusWithin
Link
Visited
AnyLink
Enabled
Disabled
Checked
Indeterminate
Required
Optional
Valid
Invalid
ReadOnly
ReadWrite
}

Pseudo-class selector
impl Show for PseudoClass

#
PseudoElement

pub enum PseudoElement {
Before
After
FirstLine
FirstLetter
Marker
Placeholder
Selection
}

Pseudo-element selector

#
RelativeSelector

pub struct RelativeSelector {
combinator : Combinator?
selector : ComplexSelector
}

Relative selector for :has()

#
SelectorList

pub struct SelectorList {
selectors : Array[ComplexSelector]
}

Selector list - comma-separated selectors

#
SimpleSelector

pub enum SimpleSelector {
Type(String)
Universal
Id(String)
Class(String)
Attribute(AttributeSelector)
PseudoClass(PseudoClass)
PseudoElement(PseudoElement)
}

Simple selector - a single component

#
Specificity

pub(all) struct Specificity {
a : Int
b : Int
c : Int
} derive(Compare, Eq)

Specificity as (a, b, c) tuple a: ID selectors count b: class selectors, attribute selectors, pseudo-classes count c: type selectors, pseudo-elements count
impl Show for Specificity

#
Specificity::add

fn Specificity::add(self : Specificity, other : Specificity) -> Specificity

#
Specificity::compare_to

fn Specificity::compare_to(self : Specificity, other : Specificity) -> Int

Compare specificities for cascade ordering Returns positive if self > other, negative if self < other, 0 if equal

#
Specificity::zero

fn Specificity::zero() -> Specificity

#
complex_specificity

fn complex_specificity(sel : ComplexSelector) -> Specificity

Calculate specificity of a complex selector

#
matches_complex

fn matches_complex(element : Element, selector : ComplexSelector) -> Bool

Check if an element matches a complex selector

#
matches_complex_with_forced_states

fn matches_complex_with_forced_states(element : Element, selector : ComplexSelector, forced : ForcedPseudoStates) -> Bool

Check if an element matches a complex selector with forced states. Forced states only apply to the subject element (the head/rightmost selector).

#
matches_pseudo_class_with_forced_states

fn matches_pseudo_class_with_forced_states(element : Element, pc : PseudoClass, forced : ForcedPseudoStates) -> Bool

Check if an element matches a pseudo-class with forced states applied.

#
matches_selector_list

fn matches_selector_list(element : Element, list : SelectorList) -> Bool

Check if an element matches any selector in a list

#
parse_selector_list_text

fn parse_selector_list_text(css : String) -> SelectorList?

Convenience function to parse a selector list from CSS text

#
parse_selector_text

fn parse_selector_text(css : String) -> ComplexSelector?

Convenience function to parse a selector from CSS text

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io