Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Inheritable<Self, Root, Parent, Child, Token>

Type parameters

Hierarchy

Implements

  • SelectorFactory

Index

Constructors

constructor

Properties

Protected _base

_base: Self | undefined

Protected _children

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

Protected _parent

_parent: Parent | null

Protected _root

_root: Root | Self

Protected _token

_token: Token

Private parsedRuleSelectors

parsedRuleSelectors: WeakMap<Rule, ParsedSelector[]> | null

Accessors

Protected ChildConstructor

  • get ChildConstructor(): object | never

base

  • get base(): Self | undefined
  • 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 Self | undefined

block

  • get block(): Root
  • 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 Root

    The base node in this tree.

Private isRootNode

  • get isRootNode(): boolean

Protected parent

  • get parent(): Parent

Protected root

  • get root(): Root

token

  • get token(): Token

Protected uid

  • get uid(): string

Methods

Private asSelf

  • asSelf(): Self

Private childToUid

  • childToUid(token: Child["token"]): string

Protected children

  • children(): Child[]

Protected childrenHash

  • childrenHash(): ObjectDictionary<Child>
  • Returns a hash of all children nodes at the keys they are stored.. TODO: Cache this maybe? Convert entire model to only use hash?...

    Returns ObjectDictionary<Child>

    The children hash.

Protected childrenMap

  • childrenMap(): Map<string, Child>

Protected ensureChild

  • ensureChild(token: Child["token"], key?: undefined | string): Child
  • 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 Child

    The child node.

Protected getChild

  • getChild(token: Child["token"]): Child | 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

Protected newChild

  • newChild(token: Child["token"]): Child

Protected resolveChild

  • resolveChild(token: Child["token"]): Child | null
  • Resolves the child with the given name from this node's inheritance chain. Returns null if the child is not found.

    Parameters

    • token: Child["token"]

    Returns Child | null

    The child node, or null

Protected resolveChildren

  • resolveChildren(): Child[]
  • Returns an array of all children nodes in the order they were added for self and all inherited children.

    Returns Child[]

    The children array.

Protected resolveChildrenHash

  • resolveChildrenHash(): ObjectDictionary<Child>

Protected resolveChildrenMap

  • resolveChildrenMap(): Map<string, Child>

resolveInheritance

  • resolveInheritance(): Self[]
  • 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 Self[]

    The array of nodes this node inherits from.

Protected setChild

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

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