Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface TreeAdapter

Tree adapter is a set of utility functions that provides minimal required abstraction layer beetween parser and a specific AST format. Note that TreeAdapter is not designed to be a general purpose AST manipulation library. You can build such library on top of existing TreeAdapter or use one of the existing libraries from npm.

see

default implementation

Hierarchy

  • TreeAdapter

Index

Methods

adoptAttributes

  • Copies attributes to the given element. Only attributes that are not yet present in the element are copied.

    Parameters

    • recipient: Element

      Element to copy attributes into.

    • attrs: Attribute[]

      Attributes to copy.

    Returns void

appendChild

  • Appends a child node to the given parent node.

    Parameters

    Returns void

createCommentNode

createDocument

createDocumentFragment

createElement

  • createElement(tagName: string, namespaceURI: string, attrs: Attribute[]): Element
  • Creates an element node.

    Parameters

    • tagName: string

      Tag name of the element.

    • namespaceURI: string

      Namespace of the element.

    • attrs: Attribute[]

      Attribute name-value pair array. Foreign attributes may contain namespace and prefix fields as well.

    Returns Element

detachNode

  • detachNode(node: Node): void
  • Removes a node from its parent.

    Parameters

    • node: Node

      Node to remove.

    Returns void

getAttrList

  • Returns the given element's attributes in an array, in the form of name-value pairs. Foreign attributes may contain namespace and prefix fields as well.

    Parameters

    Returns Attribute[]

getChildNodes

getCommentNodeContent

  • getCommentNodeContent(commentNode: CommentNode): string
  • Returns the given comment node's content.

    Parameters

    Returns string

getDocumentMode

getDocumentTypeNodeName

  • getDocumentTypeNodeName(doctypeNode: DocumentType): string
  • Returns the given document type node's name.

    Parameters

    Returns string

getDocumentTypeNodePublicId

  • getDocumentTypeNodePublicId(doctypeNode: DocumentType): string
  • Returns the given document type node's public identifier.

    Parameters

    Returns string

getDocumentTypeNodeSystemId

  • getDocumentTypeNodeSystemId(doctypeNode: DocumentType): string
  • Returns the given document type node's system identifier.

    Parameters

    Returns string

getFirstChild

getNamespaceURI

  • getNamespaceURI(element: Element): string
  • Returns the given element's namespace.

    Parameters

    Returns string

getParentNode

getTagName

  • getTagName(element: Element): string
  • Returns the given element's tag name.

    Parameters

    Returns string

getTemplateContent

getTextNodeContent

  • getTextNodeContent(textNode: TextNode): string
  • Returns the given text node's content.

    Parameters

    Returns string

insertBefore

  • Inserts a child node to the given parent node before the given reference node.

    Parameters

    • parentNode: ParentNode

      Parent node.

    • newNode: Node

      Child node.

    • referenceNode: Node

      Reference node.

    Returns void

insertText

  • insertText(parentNode: ParentNode, text: string): void
  • Inserts text into a node. If the last child of the node is a text node, the provided text will be appended to the text node content. Otherwise, inserts a new text node with the given text.

    Parameters

    • parentNode: ParentNode

      Node to insert text into.

    • text: string

      Text to insert.

    Returns void

insertTextBefore

  • insertTextBefore(parentNode: ParentNode, text: string, referenceNode: Node): void
  • Inserts text into a sibling node that goes before the reference node. If this sibling node is the text node, the provided text will be appended to the text node content. Otherwise, inserts a new sibling text node with the given text before the reference node.

    Parameters

    • parentNode: ParentNode

      Node to insert text into.

    • text: string

      Text to insert.

    • referenceNode: Node

      Node to insert text before.

    Returns void

isCommentNode

  • isCommentNode(node: Node): boolean
  • Determines if the given node is a comment node.

    Parameters

    Returns boolean

isDocumentTypeNode

  • isDocumentTypeNode(node: Node): boolean
  • Determines if the given node is a document type node.

    Parameters

    Returns boolean

isElementNode

  • isElementNode(node: Node): boolean
  • Determines if the given node is an element.

    Parameters

    Returns boolean

isTextNode

  • isTextNode(node: Node): boolean
  • Determines if the given node is a text node.

    Parameters

    Returns boolean

setDocumentMode

setDocumentType

  • setDocumentType(document: Document, name: string, publicId: string, systemId: string): void
  • Sets the document type. If the document already contains a document type node, the name, publicId and systemId properties of this node will be updated with the provided values. Otherwise, creates a new document type node with the given properties and inserts it into the document.

    Parameters

    • document: Document

      Document node.

    • name: string

      Document type name.

    • publicId: string

      Document type public identifier.

    • systemId: string

      Document type system identifier.

    Returns void

setTemplateContent

  • Sets the <template> element content element.

    Parameters

    Returns void

Generated using TypeDoc