Options
All
  • Public
  • Public/Protected
  • All
Menu

Class BlockClass<Token, Token>

Represents a Class present in the Block.

Type parameters

  • Token: any

  • Token: any

Hierarchy

Implements

  • SelectorFactory

Index

Constructors

constructor

Properties

Protected _base

_base: BlockClass | undefined

Protected _children

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

Protected _parent

_parent: Block | null

Protected _root

_root: Block | BlockClass

Private _sourceAttribute

_sourceAttribute: Attr | undefined

Protected _token

_token: Token

rulesets

Accessors

Protected ChildConstructor

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 BlockClass | 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.

isRoot

  • get isRoot(): boolean

name

  • get name(): string

Protected parent

Protected root

token

  • get token(): Token

Protected uid

  • get uid(): string

Methods

all

  • all(shallow?: undefined | true | false): Styles[]

allAttributeValues

asDebug

asSource

  • asSource(scope?: Block | boolean): string
  • Export as original class 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 class.

asSourceAttributes

  • asSourceAttributes(optionalRoot?: boolean): Attr[]
  • Emit analysis attributes for the class value this block class represents in it's authored source format.

    Parameters

    • Default value optionalRoot: boolean = false

      The root class is optional on root-level Attributes. So when these attributes are being used in conjunction with a Attributes, this value is set to true.

    Returns Attr[]

attributes

booleanAttributeValues

Protected children

Protected childrenHash

  • childrenHash(): ObjectDictionary<Attribute>

Protected childrenMap

cssClass

cssClasses

debug

ensureAttribute

ensureAttributeValue

  • Ensure that an AttrValue within the provided Attribute exists. If the AttrValue does not exist, it is created.

    Parameters

    • token: AttrToken | string

      The AttrValue to ensure exists. This may either be an AttrToken, or a string of the format [namespace|name(="value")]

    Returns AttrValue

    The AttrValue object.

Protected ensureChild

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

    The child node.

getAttribute

getAttributeValue

  • AttrValue getter. Returns the AttrValue object in the requested Attribute, without inheritance.

    Parameters

    • token: AttrToken | string

      AttrToken or attribute BlockPath string for lookup.

    Returns AttrValue | null

    The AttrValue that was requested, or null.

getAttributeValues

getAttributes

Protected getChild

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

getGroupsNames

  • getGroupsNames(): Set<string>

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

Protected newChild

resolveAttribute

resolveAttributeValue

  • AttrValue getter. Returns the AttrValue object in the requested Attribute, with inheritance.

    Parameters

    • token: AttrToken | string

      AttrToken or attribute BlockPath string for lookup.

    Returns AttrValue | null

    The AttrValue that was requested, or null.

resolveAttributeValues

  • Resolves all AttrValues from this Attribute's inheritance chain. Returns an empty object if no

    Parameters

    • Optional token: AttrToken | string

      The AttrToken or attribute BlockPath of the Attribute to resolve.

    Returns Map<string, AttrValue>

Protected resolveChild

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

Protected resolveChildren

Protected resolveChildrenHash

  • resolveChildrenHash(): ObjectDictionary<Attribute>

Protected resolveChildrenMap

  • resolveChildrenMap(): Map<string, Attribute>

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 BlockClass[]

    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<BlockClass>

Protected setChild

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