Skip to content

Latest commit

 

History

History
250 lines (158 loc) · 6.5 KB

Ast.md

File metadata and controls

250 lines (158 loc) · 6.5 KB

Namespace: Ast

Table of contents

Type Aliases

Type Aliases

AttributePresenceSelector

Ƭ AttributePresenceSelector: Object

Attribute presence selector.

https://www.w3.org/TR/selectors/#attribute-selectors

parseley considers attribute presence and value selectors to be unrelated entities for simplicity of processing.

Type declaration

Name Type
name string
namespace string | null
specificity Specificity
type "attrPresence"

AttributeValueSelector

Ƭ AttributeValueSelector: Object

Attribute value selector.

https://www.w3.org/TR/selectors/#attribute-selectors

parseley considers attribute presence and value selectors to be unrelated entities for simplicity of processing.

Type declaration

Name Type
matcher "=" | "~=" | "|=" | "^=" | "$=" | "*="
modifier "i" | "s" | null
name string
namespace string | null
specificity Specificity
type "attrValue"
value string

ClassSelector

Ƭ ClassSelector: Object

Class selector.

https://www.w3.org/TR/selectors/#class-html

Type declaration

Name Type
name string
specificity Specificity
type "class"

Combinator

Ƭ Combinator: Object

Represents a selectors combinator with what's on the left side of it.

https://www.w3.org/TR/selectors/#combinators

Type declaration

Name Type
combinator " " | "+" | ">" | "~" | "||"
left CompoundSelector
specificity Specificity
type "combinator"

CompoundSelector

Ƭ CompoundSelector: Object

Compound selector - a set of conditions describing a single element.

https://www.w3.org/TR/selectors/#compound

https://www.w3.org/TR/selectors/#complex

Important note: due to the way parseley represents combinators, every compound selector is also a complex selector with everything connected from the left side. Specificity value also includes any extra weight added by the left side.

If there is a combinator in the selector - it is guaranteed to be the last entry in the list of inner selectors.

Type declaration

Name Type
list SimpleSelector[]
specificity Specificity
type "compound"

IdSelector

Ƭ IdSelector: Object

Id selector.

https://www.w3.org/TR/selectors/#id-selectors

Type declaration

Name Type
name string
specificity Specificity
type "id"

ListSelector

Ƭ ListSelector: Object

Represents a comma-separated list of compound selectors.

https://www.w3.org/TR/selectors/#selector-list

As this kind of selector can combine different ways to match elements, a single specificity value doesn't make sense for it and therefore absent.

Type declaration

Name Type
list CompoundSelector[]
type "list"

Selector

Ƭ Selector: ListSelector | CompoundSelector | SimpleSelector

Any kind of selector supported by parseley.


SimpleSelector

Ƭ SimpleSelector: UniversalSelector | TagSelector | ClassSelector | IdSelector | AttributePresenceSelector | AttributeValueSelector | Combinator

Any thing representing a single condition on an element.

https://www.w3.org/TR/selectors/#simple

parseley deviates from the spec here by adding Combinator to the enumeration. This is done for simplicity of processing.

Combinator effectively considered an extra condition on a specific element ("have this kind of element in relation").


Specificity

Ƭ Specificity: [number, number, number]

Specificity as defined by Selectors spec.

https://www.w3.org/TR/selectors/#specificity

Three levels: for id, class, tag (type).

Extra level(s) used in HTML styling don't fit the scope of this package and no space reserved for them.


TagSelector

Ƭ TagSelector: Object

Tag name (type) selector.

https://www.w3.org/TR/selectors/#type-selectors

parseley considers tag name and universal selectors to be unrelated entities for simplicity of processing.

Type declaration

Name Type
name string
namespace string | null
specificity Specificity
type "tag"

UniversalSelector

Ƭ UniversalSelector: Object

The * selector.

https://www.w3.org/TR/selectors/#the-universal-selector

parseley considers tag name and universal selectors to be unrelated entities for simplicity of processing.

Type declaration

Name Type
namespace string | null
specificity Specificity
type "universal"