Options
All
  • Public
  • Public/Protected
  • All
Menu

tag. Defines a slot that can receive a DOM subtree from

Hierarchy

Index

Constructors

constructor

  • new MSlotNode(slot?: string, attributes?: Map<string, unknown>): MSlotNode

Properties

Protected attributes

attributes: Map<string, unknown>

Attributes on this tag node. Do not modify directly, use attribute API instance methods.

childNodes

childNodes: Node[] = []

Children of this node. Do not modify this directly, use NodeLogic or instance methods.

nextSibling

nextSibling: null | Node = null

Next sibling node, or null if none exists. Do not modify this directly, use NodeLogic or instance methods.

Readonly nodeData

nodeData: Record<PropertyKey, unknown> = {}

Extra DOM data associated with this node. This object prototypically inherits from the parent node's nodeData.

Readonly nodeTags

nodeTags: Set<string> = ...

Set of unique string tags applied to this node. These tags do not inherit and are unique to each instance. Meaning is tag-specific.

Readonly nodeType

nodeType: NodeType

Type of this node

parentNode

parentNode: null | NodeWithChildren = null

Parent of this node, or null if there is none. Do not modify this directly, use NodeLogic or instance methods.

prevSibling

prevSibling: null | Node = null

Previous sibling node, or null if none exists. Do not modify this directly, use NodeLogic or instance methods.

Readonly tagName

tagName: string

Name of the tag

Static Readonly DefaultSlotName

DefaultSlotName: "[default]" = '[default]'

Accessors

firstChild

  • get firstChild(): null | Node
  • The first child node of this parent, or null if there are no children.

    Returns null | Node

firstChildTag

  • get firstChildTag(): null | TagNode

firstChildText

lastChild

  • get lastChild(): null | Node
  • The last child node of this parent, or null if there are no children.

    Returns null | Node

lastChildTag

  • get lastChildTag(): null | TagNode

lastChildText

nextSiblingTag

  • get nextSiblingTag(): null | TagNode
  • The closest following sibling that is a TagNode, or null if none exists.

    Returns null | TagNode

nextSiblingText

  • get nextSiblingText(): null | TextNode

prevSiblingTag

  • get prevSiblingTag(): null | TagNode
  • The closest previous sibling that is a TagNode, or null if none exists.

    Returns null | TagNode

prevSiblingText

  • get prevSiblingText(): null | TextNode

slot

  • get slot(): string
  • set slot(newSlotName: string): void

Methods

appendChild

  • appendChild(child: Node): void

appendChildren

  • appendChildren(children: Node[]): void

appendSibling

  • appendSibling(node: Node): void

clear

  • clear(): void

clone

  • clone(deep?: boolean, callback?: (oldNode: Node, newNode: Node) => void): MSlotNode

createDomFromChildren

deleteAttribute

  • deleteAttribute(name: string): void

findChildNode

  • findChildNode(matcher: (node: Node) => boolean, deep?: boolean): null | Node
  • Finds the first child node that matches a condition. Returns null if no match found.

    Parameters

    • matcher: (node: Node) => boolean

      Callback to test condition

        • (node: Node): boolean
        • Parameters

          Returns boolean

    • deep: boolean = true

      If true, children of child nodes will also be searched.

    Returns null | Node

    First matching child, or null

findChildNodeByNodeType

findChildNodes

  • findChildNodes(matcher: (node: Node) => boolean, deep?: boolean): Node[]
  • Finds all child nodes that match a condition. Returns an empty array if no matches found.

    Parameters

    • matcher: (node: Node) => boolean

      Callback to test condition

        • (node: Node): boolean
        • Parameters

          Returns boolean

    • deep: boolean = true

      If true, children of child nodes will also be searched.

    Returns Node[]

    Array of all Nodes that match condition

findChildNodesByNodeType

findChildTag

  • findChildTag(matcher: (tag: TagNode) => boolean, deep?: boolean): null | TagNode
  • Finds the first child TagNode that matches a condition. Returns null if no match found.

    Parameters

    • matcher: (tag: TagNode) => boolean

      Callback to test condition

    • deep: boolean = true

      If true, children of child nodes will also be searched.

    Returns null | TagNode

    First TagNode that matches the condition, or null.

findChildTagByTagName

  • findChildTagByTagName(tagName: "m-fragment", deep?: boolean): null | MFragmentNode
  • findChildTagByTagName(tagName: "m-content", deep?: boolean): null | MContentNode
  • findChildTagByTagName(tagName: "m-slot", deep?: boolean): null | MSlotNode
  • findChildTagByTagName(tagName: "m-var", deep?: boolean): null | MVarNode
  • findChildTagByTagName(tagName: "m-scope", deep?: boolean): null | MScopeNode
  • findChildTagByTagName(tagName: "m-import", deep?: boolean): null | MImportNode
  • findChildTagByTagName(tagName: "m-if", deep?: boolean): null | MIfNode
  • findChildTagByTagName(tagName: "m-for", deep?: boolean): null | MForNode
  • findChildTagByTagName(tagName: "m-data", deep?: boolean): null | MDataNode
  • findChildTagByTagName(tagName: "style", deep?: boolean): null | StyleNode
  • findChildTagByTagName(tagName: "script", deep?: boolean): null | ScriptNode
  • findChildTagByTagName(tagName: "a", deep?: boolean): null | AnchorNode
  • findChildTagByTagName(tagName: "m-whitespace", deep?: boolean): null | MWhitespaceNode
  • findChildTagByTagName(tagName: string, deep?: boolean): null | TagNode

findChildTags

  • findChildTags(matcher: (tag: TagNode) => boolean, deep?: boolean): TagNode[]
  • Finds all child TagNodes that match a condition. Returns an empty array if no matches found.

    Parameters

    • matcher: (tag: TagNode) => boolean

      Callback to test condition

    • deep: boolean = true

      If true, children of child nodes will also be searched.

    Returns TagNode[]

    Array of all TagNodes that match condition

findChildTagsByTagName

  • findChildTagsByTagName(tagName: "m-fragment", deep?: boolean): MFragmentNode[]
  • findChildTagsByTagName(tagName: "m-content", deep?: boolean): MContentNode[]
  • findChildTagsByTagName(tagName: "m-slot", deep?: boolean): MSlotNode[]
  • findChildTagsByTagName(tagName: "m-var", deep?: boolean): MVarNode[]
  • findChildTagsByTagName(tagName: "m-scope", deep?: boolean): MScopeNode[]
  • findChildTagsByTagName(tagName: "m-import", deep?: boolean): MImportNode[]
  • findChildTagsByTagName(tagName: "m-if", deep?: boolean): MIfNode[]
  • findChildTagsByTagName(tagName: "m-for", deep?: boolean): MForNode[]
  • findChildTagsByTagName(tagName: "m-data", deep?: boolean): MDataNode[]
  • findChildTagsByTagName(tagName: "style", deep?: boolean): StyleNode[]
  • findChildTagsByTagName(tagName: "script", deep?: boolean): ScriptNode[]
  • findChildTagsByTagName(tagName: "a", deep?: boolean): AnchorNode[]
  • findChildTagsByTagName(tagName: "m-whitespace", deep?: boolean): MWhitespaceNode[]
  • findChildTagsByTagName(tagName: string, deep?: boolean): TagNode[]

findNext

  • findNext(matcher: (node: Node) => boolean, deep?: boolean): null | Node
  • Finds the next node that matches a callback. The next node is defined as the first matching child, sibling, or sibling's child node starting from this node. This only checks child and sibling nodes, it will not move further up the DOM tree. To check only sibling nodes, set node to false.

    Parameters

    • matcher: (node: Node) => boolean

      Callback to test nodes

        • (node: Node): boolean
        • Parameters

          Returns boolean

    • deep: boolean = true

      If true or not specified, then child nodes will be checked

    Returns null | Node

    The first matching node, or null if none found.

getAttribute

  • getAttribute(name: string): undefined | null | string
  • Gets the value of an attribute, or undefined the attribute does not exist

    Parameters

    • name: string

      Name of the attribute

    Returns undefined | null | string

    Value of the attribute, converted to a string if not null or undefined

getAttributes

  • getAttributes(): ReadonlyMap<string, unknown>
  • Gets a ReadonlyMap containing all attributes on this tag. Attributes are exposed raw - not converted to strings.

    Returns ReadonlyMap<string, unknown>

    a read-only Map containing all attributes

getChildTags

getOptionalValueAttribute

  • getOptionalValueAttribute(name: string): undefined | string
  • Gets the value of an attribute, or returns undefined if the attribute does not exist. Throws an exception if attribute value is null.

    throws

    If the attribute exists but is null

    Parameters

    • name: string

      Name of the attribute

    Returns undefined | string

    Value of the attribute (converted to a string) or undefined if it does not exist

getRawAttribute

  • getRawAttribute(name: string): unknown

getRequiredAttribute

  • getRequiredAttribute(name: string): null | string
  • Gets the value of an attribute, or throws an exception if the attribute does not exist

    throws

    If the attribute does not exist

    Parameters

    • name: string

      Name of the attribute

    Returns null | string

    Value of the attribute, converted to a string if not null

getRequiredValueAttribute

  • getRequiredValueAttribute(name: string): string
  • Gets the value of an attribute, or throws an exception if the attribute does not exist or the value is null

    throws

    If the attribute does not exist

    throws

    If the attribute is null

    Parameters

    • name: string

      Name of the attribute

    Returns string

    Value of the attribute, converted to a string

hasAttribute

  • hasAttribute(name: string): boolean

hasValueAttribute

  • hasValueAttribute(name: string): boolean
  • Checks if this tag has a specified attribute with a non-null and non-undefined value

    Parameters

    • name: string

      Name of the attribute

    Returns boolean

    True if the attribute exists and is non-nullish, false otherwise

prependChild

  • prependChild(child: Node): void

prependChildren

  • prependChildren(children: Node[]): void

prependSibling

  • prependSibling(node: Node): void

removeSelf

  • removeSelf(keepChildren?: boolean): void
  • Removes this node from the DOM, but optionally preserves children. If keepChildren is true, then child nodes will be reattached to the DOM in place of this node. Effectively "promotes" child nodes.

    Parameters

    • keepChildren: boolean = false

      If true, child nodes will be kept.

    Returns void

replaceSelf

  • replaceSelf(nodes: Node[]): void

setAttribute

  • setAttribute(name: string, value: null | string): void

setBooleanAttribute

  • setBooleanAttribute(name: string, value: boolean): void
  • Sets the value of a boolean attribute. A boolean attribute has no value, it only exists or does not exist.

    Parameters

    • name: string

      Name of the attribute

    • value: boolean

      Value of the attribute

    Returns void

setOptionalValueAttribute

  • setOptionalValueAttribute(name: string, value: undefined | string): void

setRawAttribute

  • setRawAttribute(name: string, value: unknown): void

setRequiredValueAttribute

  • setRequiredValueAttribute(name: string, value: string): void

toHtml

  • toHtml(): string

Static isMSlotNode

Static isNodeWithChildren

Static isTagNode

Generated using TypeDoc