Selectors which start with one colon, e.g.
More...
#include "donner/css/selectors/PseudoClassSelector.h"
|
|
RcString | ident |
| | The name of the pseudo-class.
|
|
std::optional< std::vector< ComponentValue > > | argsIfFunction |
| | The arguments of the pseudo-class, if it is a function.
|
|
std::optional< AnbValue > | anbValueIfAnb |
| | The An+B value of the pseudo-class, for An+B pseudo-classes such as :nth-child.
|
|
std::unique_ptr< Selector > | selector |
| | The selector of the pseudo-class, for pseudo-classes such as :is() and :not(), or :nth-child(An+B of S).
|
Selectors which start with one colon, e.g.
:nth-child(), are called pseudo-classes, and they represent additional state information not directly present in the document tree.
Each pseudo-class selector has a unique behavior.
Selectors supported:
- :nth-child(An+B [of S]) - Selects the element if its index within its parent is An+B (1-based) when counting from the first element that would be selected by S. If S is omitted, the selector matches only elements that are direct children of their parent.
- :nth-last-child(An+B [of S]) - Selects the element if its index within its parent is An+B (1-based) when counting from the last element that would be selected by S. If S is omitted, the selector matches only elements that are direct children of their parent.
- :nth-of-type(An+B) - Selects the element if its index within its parent's children of the same type is An+B (1-based).
- :nth-last-of-type(An+B) - Selects the element if its index within its parent's children of the same type is An+B (1-based).
- :first-child - Selects the element if it is the first child of its parent.
- :last-child - Selects the element if it is the last child of its parent.
- :first-of-type - Selects the element if it is the first child of its parent and its type is the same as its parent.
- :last-of-type - Selects the element if it is the last child of its parent and its type is the same as its parent.
- :only-child - Selects the element if it is the only child of its parent.
- :only-of-type - Selects the element if it is the only child of its parent and its type is the same as its parent.
- :empty - Selects the element if it has no children.
- :root - Selects the element if it is the root of the document.
- :is(S) - Selects the element if it matches any of the selectors in the argument list.
- :not(S) - Selects the element if it does not match S.
- :where(S) - Selects the element if it matches any of the selectors in the argument list.
- :scope - Selects the reference element used to anchor a scoped query.
- :has(S) - Selects an element if a relative selector in S matches from that anchor.
- :defined - Selects if the element is supported by the user agent (donner svg in this case).
Pseudo-classes are defined in the following specs:
- Linguistic Pseudo-classes, such as :dir() and :lang(), https://www.w3.org/TR/selectors-4/#linguistic-pseudos
- Location Pseudo-classes, such as :link and :visited, https://www.w3.org/TR/selectors-4/#location
- User Action Pseudo-classes, such as :hover and :active, https://www.w3.org/TR/selectors-4/#useraction-pseudos
- Time-dimensional Pseudo-classes, such as :current and :past, https://www.w3.org/TR/selectors-4/#time-pseudos
- Resource State Pseudo-classes, such as :playing and :muted, https://www.w3.org/TR/selectors-4/#resource-pseudos
- Element Display State Pseudo-classes, such as :open and :fullscreen, https://www.w3.org/TR/selectors-4/#display-state-pseudos
- Input Pseudo-classes, such as :enabled and :checked, https://www.w3.org/TR/selectors-4/#input-pseudos
- Tree-Structural Pseudo-classes, such as :empty and :nth-child(), https://www.w3.org/TR/selectors-4/#structural-pseudos
◆ PseudoClassSelector()
| donner::css::PseudoClassSelector::PseudoClassSelector |
( |
const RcString & | ident | ) |
|
|
explicit |
Create a PseudoClassSelector with the given ident.
- Parameters
-
| ident | The name of the pseudo-class. |
◆ isValid()
| bool donner::css::PseudoClassSelector::isValid |
( |
| ) |
const |
◆ matches()
Returns true if the provided element matches this selector.
- Template Parameters
-
| T | A type that fulfills the ElementLike concept, to enable traversing the tree to match the selector. |
- Parameters
-
| element | The element to check. |
| options | The options to use when matching |
The documentation for this struct was generated from the following files: