Options
All
  • Public
  • Public/Protected
  • All
Menu

Updates a GUI tree so that its data nodes (those nodes that are not decorations) mirror a data tree.

Hierarchy

Index

Constructors

constructor

Properties

Protected _events

_events: Subject<TreeUpdaterEvents>

Protected dlocRoot

dlocRoot: DLocRoot

events

events: Observable<TreeUpdaterEvents>

Private haveTooltips

haveTooltips: HTMLCollectionOf<Element>

Protected tree

tree: Element | Document

The node which contains the tree to update.

Private treeUpdater

treeUpdater: TreeUpdater

A tree updater that updates the data tree. It serves as a source of modification events which the object being created will listen on.

Methods

Private _beforeDeleteNodeHandler

Protected _emit

Private _insertNodeAtHandler

Private _setAttributeNSHandler

Private _setTextNodeValueHandler

Protected _splitAt

  • _splitAt(top: Node, node: Node, index: number): SplitResult
  • Splits a DOM tree into two halves.

    Parameters

    • top: Node

      The node at which the splitting operation should end. This node will be split but the function won't split anything above this node.

    • node: Node

      The node at which to start.

    • index: number

      The index at which to start in the node.

    Returns SplitResult

    An array containing in order the first and second half of the split.

cut

  • A complex method. Removes the contents between the start and end carets from the DOM tree. If two text nodes become adjacent, they are merged.

    throws

    {Error} If Nodes in the range are not in the same element.

    Parameters

    • start: DLoc

      The start position.

    • end: DLoc

      The end position.

    Returns [DLoc, Node[]]

    A pair of items. The first item is a DLoc object indicating the position where the cut happened. The second item is a list of nodes, the cut contents.

deleteNode

  • deleteNode(node: Node): void
  • A primitive method. Removes a node from the DOM tree. This method must not be called directly by code that performs changes of the DOM tree at a high level, because it does not prevent two text nodes from being contiguous after deletion of the node. Call removeNode instead. This method is meant to be used by other complex methods of TreeUpdater and by some low-level facilities of wed.

    emits

    DeleteNodeEvent

    emits

    BeforeDeleteNodeEvent

    emits

    ChangedEvent

    Parameters

    • node: Node

      The node to remove

    Returns void

deleteText

  • deleteText(loc: DLoc, length: number): void
  • deleteText(node: Text, index: number, length: number): void

fromDataLocation

  • fromDataLocation(loc: DLoc): DLoc | null
  • fromDataLocation(node: Node, offset: number): DLoc | null

insertAt

  • A complex method. This is a convenience method that will call primitive methods to insert the specified item at the specified location. Note that this method returns nothing even if the primitives it uses return some information.

    throws

    {Error} If loc is not in an element or text node or if what is not an element or text node.

    Parameters

    • loc: DLoc

      The location where to insert.

    • what: Insertable

      The data to insert.

    Returns void

  • Parameters

    Returns void

insertBefore

  • insertBefore(parent: Element, toInsert: Element | Text, beforeThis: Node | null): void
  • A complex method. Inserts the specified item before another one. Note that the order of operands is the same as for the insertBefore DOM method.

    throws

    {Error} If beforeThis is not a child of parent.

    Parameters

    • parent: Element

      The node that contains the two other parameters.

    • toInsert: Element | Text

      The node to insert.

    • beforeThis: Node | null

      The node in front of which to insert. A value of null results in appending to the parent node.

    Returns void

insertIntoText

  • A complex method. Inserts an element into text, effectively splitting the text node in two. This function takes care to modify the DOM tree only once.

    throws

    {Error} If the node to insert is undefined or null.

    Parameters

    • loc: DLoc

      The location at which to cut.

    • node: Node

      The node to insert.

    Returns InsertionBoundaries

    The first element of the array is a DLoc at the boundary between what comes before the material inserted and the material inserted. The second element of the array is a DLoc at the boundary between the material inserted and what comes after. If I insert "foo" at position 2 in "abcd", then the final result would be "abfoocd" and the first location would be the boundary between "ab" and "foo" and the second location the boundary between "foo" and "cd".

  • Parameters

    • parent: Text
    • index: number
    • node: Node

    Returns InsertionBoundaries

insertNodeAt

  • insertNodeAt(loc: DLoc, node: Node): void
  • insertNodeAt(parent: Node, index: number, node: Node): void

insertText

  • A complex method. Inserts text into a node. This function will use already existing text nodes whenever possible rather than create a new text node.

    throws

    {Error} If node is not an element or text Node type.

    Parameters

    • loc: DLoc

      The location at which to insert the text.

    • text: string

      The text to insert.

    • Optional caretAtEnd: undefined | true | false

      Whether the returned caret should be at the end of the inserted text or the start. If not specified, the default is true.

    Returns TextInsertionResult

    The result of inserting text.

  • Parameters

    • node: Node
    • index: number
    • text: string
    • Optional caretAtEnd: undefined | true | false

    Returns TextInsertionResult

mergeTextNodes

  • mergeTextNodes(node: Node): DLoc
  • A complex method. If the node is a text node and followed by a text node, this method will combine them.

    Parameters

    • node: Node

      The node to check. This method will fail with an exception if this parameter is undefined or null. Use mergeTextNodesNF if you want a method that will silently do nothing if undefined or null are expected values.

    Returns DLoc

    A position between the two parts that were merged, or between the two nodes that were not merged (because they were not both text).

mergeTextNodesNF

  • mergeTextNodesNF(node: Node | null | undefined): DLoc | undefined
  • A complex method. If the node is a text node and followed by a text node, this method will combine them.

    Parameters

    • node: Node | null | undefined

      The node to check. This method will do nothing if the node to remove is undefined or null.

    Returns DLoc | undefined

    A position between the two parts that were merged, or between the two nodes that were not merged (because they were not both text). This will be undefined if there was no node to remove.

nodeToPath

  • nodeToPath(node: Node): string
  • Converts a node to a path.

    Parameters

    • node: Node

      The node for which to return a path.

    Returns string

    The path of the node relative to the root of the tree we are updating.

pathToNode

  • pathToNode(path: string): Node | null

removeNode

  • removeNode(node: Node | undefined | null): DLoc
  • A complex method. Removes a node from the DOM tree. If two text nodes become adjacent, they are merged.

    Parameters

    • node: Node | undefined | null

      The node to remove. This method will fail with an exception if this parameter is undefined or null. Use removeNodeNF if you want a method that will silently do nothing if undefined or null are expected values.

    Returns DLoc

    A location between the two parts that were merged, or between the two nodes that were not merged (because they were not both text).

removeNodeNF

  • removeNodeNF(node: Node | undefined | null): DLoc | undefined
  • A complex method. Removes a node from the DOM tree. If two text nodes become adjacent, they are merged.

    Parameters

    • node: Node | undefined | null

      The node to remove. This method will do nothing if the node to remove is undefined or null.

    Returns DLoc | undefined

    A location between the two parts that were merged, or between the two nodes that were not merged (because they were not both text). This will be undefined if there was no node to remove.

removeNodes

  • removeNodes(nodes: Node[]): DLoc | undefined
  • A complex method. Removes a list of nodes from the DOM tree. If two text nodes become adjacent, they are merged.

    throws

    {Error} If nodes are not contiguous siblings.

    Parameters

    • nodes: Node[]

      These nodes must be immediately contiguous siblings in document order.

    Returns DLoc | undefined

    The location between the two parts that were merged, or between the two nodes that were not merged (because they were not both text). Undefined if the list of nodes is empty.

removeTooltips

  • removeTooltips(el: Element): void
  • Check whether a tooltip should be destroyed when the element is removed from the tree. This function checks whether the element or any descendant has a tooltip.

    Parameters

    • el: Element

      An element to check.

    Returns void

setAttribute

  • setAttribute(node: Element, attribute: string, value: string | null | undefined): void
  • A complex method. Sets an attribute to a value. Setting to the value null or undefined deletes the attribute. This method sets attributes outside of any namespace.

    emits

    SetAttributeNSEvent

    emits

    ChangedEvent

    Parameters

    • node: Element

      The node to modify.

    • attribute: string

      The name of the attribute to modify.

    • value: string | null | undefined

      The value to give to the attribute.

    Returns void

setAttributeNS

  • setAttributeNS(node: Element, ns: string, attribute: string, value: string | null | undefined): void
  • A primitive method. Sets an attribute to a value. Setting to the value null or undefined deletes the attribute.

    emits

    SetAttributeNSEvent

    emits

    ChangedEvent

    Parameters

    • node: Element

      The node to modify.

    • ns: string

      The URI of the namespace of the attribute.

    • attribute: string

      The name of the attribute to modify.

    • value: string | null | undefined

      The value to give to the attribute.

    Returns void

setTextNode

  • setTextNode(node: Text, value: string): void
  • A complex method. Sets a text node to a specified value.

    throws

    {Error} If called on a non-text Node type.

    Parameters

    • node: Text

      The node to modify.

    • value: string

      The new value of the node.

    Returns void

setTextNodeValue

  • setTextNodeValue(node: Text, value: string): void
  • A primitive method. Sets a text node to a specified value. This method must not be called directly by code that performs changes of the DOM tree at a high level, because it does not prevent a text node from becoming empty. Call TreeUpdater.setTextNode instead. This method is meant to be used by other complex methods of TreeUpdater and by some low-level facilities of wed.

    emits

    SetTextNodeValueEvent

    emits

    ChangedEvent

    throws

    {Error} If called on a non-text Node type.

    Parameters

    • node: Text

      The node to modify. Must be a text node.

    • value: string

      The new value of the node.

    Returns void

splitAt

  • A complex method. Splits a DOM tree into two halves.

    throws

    {Error} If the split location is not inside the top node or if the call would merely split a text node in two.

    Parameters

    • top: Node

      The node at which the splitting operation should end. This node will be split but the function won't split anything above this node.

    • loc: DLoc

      The location where to start the split.

    Returns SplitResult

    An array containing in order the first and second half of the split.

  • Parameters

    • top: Node
    • node: Node
    • index: number

    Returns SplitResult

Generated using TypeDoc