Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AttrValue<Token, Token>

AttrValue represents the value of an Attribute in a particular Block. An Attribute can have many AttrValue children that are considered to be mutually exclusive. Attributes can be designated as "global";

Type parameters

  • Token: any

  • Token: any

Hierarchy

Implements

  • SelectorFactory

Index

Constructors

constructor

Properties

Protected _base

_base: AttrValue | undefined

Protected _children

_children: Map<string, never> = new Map()

Protected _parent

_parent: Attribute | null

Protected _root

_root: Block | AttrValue

Private _sourceAttributes

_sourceAttributes: Attr[] | undefined

Protected _token

_token: Token

isGlobal

isGlobal: boolean = false

rulesets

Accessors

Protected ChildConstructor

  • get ChildConstructor(): never

attribute

base

  • Get the style that this style inherits from, if any.

    This walks down the declared styles of the parent's inheritance chain, and attempts to find a matching directly declared style on each.

    The result is cached because it never changes and is decidable as soon as the style is instantiated.

    Returns AttrValue | undefined

block

  • The block property is an alias for root. This isn't the dryest place to put this line, but every extension re-declared this interface itself and I wanted it in one place.

    Returns Block

    The base node in this tree.

blockClass

isPresenceRule

  • get isPresenceRule(): boolean

Protected parent

Protected root

token

  • get token(): Token

Protected uid

  • get uid(): string

value

  • get value(): string

Methods

all

asDebug

asSource

  • asSource(scope?: Block | boolean): string
  • Export as original AttrValue name.

    Parameters

    • Optional scope: Block | boolean

      Optional scope to resolve this name relative to. If true, return the Block name instead of :scope. If a Block object, return with the local name instead of :scope.

    Returns string

    String representing original AttrValue path.

asSourceAttributes

  • asSourceAttributes(): Attr[]

Protected children

  • children(): never[]

Protected childrenHash

  • childrenHash(): ObjectDictionary<never>

Protected childrenMap

  • childrenMap(): Map<string, never>

cssClass

cssClasses

Protected ensureChild

  • ensureChild(token: Child["token"], key?: undefined | string): never
  • Ensure a child node exists on this object at key. If it does not, create it. If key is not provided, use the child name as the key.

    Parameters

    • token: Child["token"]
    • Optional key: undefined | string

      string The key at which this child object should be (optional)

    Returns never

    The child node.

Protected getChild

  • getChild(token: Child["token"]): never | null

getParsedSelectors

  • getParsedSelectors(rule: Rule): ParsedSelector[]
  • Every Block tree maintains its own local cache of parsed selectors. From any sub-inheritable, or from the root inheritable itself, given a PostCSS Rule, ensure it is present in the root Block's parsed rule selectors cache, and return the ParsedSelector array.

    Parameters

    • rule: Rule

      PostCSS Rule

    Returns ParsedSelector[]

    ParsedSelector array

impliedStyles

  • impliedStyles(): Set<AttrValue> | undefined

newChild

  • newChild(): never

Protected resolveChild

  • resolveChild(token: Child["token"]): never | null

Protected resolveChildren

  • resolveChildren(): never[]

Protected resolveChildrenHash

  • resolveChildrenHash(): ObjectDictionary<never>

Protected resolveChildrenMap

  • resolveChildrenMap(): Map<string, never>

resolveInheritance

  • Compute all block objects that are implied by this block object through inheritance. Does not include this object or the styles it implies through other relationships to this object.

    The values are returned in inheritance order, with the first value returned (if any) having no base, and the the last value returned (if any) being the base of this object.

    If nothing is inherited, this returns an empty array.

    Returns AttrValue[]

    The array of nodes this node inherits from.

resolveStyles

  • Return all Block Objects that are implied by this object. This takes inheritance, attr/class correlations, and any other declared links between styles into account.

    This block object is included in the returned result so the resolved value's size is always 1 or greater.

    Returns Set<AttrValue>

Protected setChild

  • setChild(token: Child["token"], value: never): never

Protected tokenToUid

  • tokenToUid(token: Token): string
  • The tokenToUid method would ideally be a static method, but Typescript doesn't expose class generics to static methods, so it needs to be a protected method. In order to map children to generic Tokens, we need a way to map any given Token shape to a UID. By default, we stringify the token passed to us. If more complex behavior is required, this method can be overridden.

    Parameters

    • token: Token

    Returns string

    A unique string that represents this token.

Generated using TypeDoc