The node which contains the tree to update.
The node which contains the tree to update.
Splits a DOM tree into two halves.
The node at which the splitting operation should end. This node will be split but the function won't split anything above this node.
The node at which to start.
The index at which to start in the node.
An array containing in order the first and second half of the split.
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.
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.
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.
The node to remove
A complex method. Deletes text from a text node. If the text node becomes empty, it is deleted.
Where to delete.
The length of text to delete.
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.
The location where to insert.
The data to insert.
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.
The node that contains the two other parameters.
The node to insert.
The node in front of which to insert. A value of
null
results in appending to the parent node.
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.
The location at which to cut.
The node to insert.
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".
A primitive method. Inserts a node at the specified position.
The location at which to insert.
The node to insert.
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.
The location at which to insert the text.
The text to insert.
Whether the returned caret should be at the end of the
inserted text or the start. If not specified, the default is true
.
The result of inserting text.
A complex method. If the node is a text node and followed by a text node, this method will combine them.
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.
A position between the two parts that were merged, or between the two nodes that were not merged (because they were not both text).
A complex method. If the node is a text node and followed by a text node, this method will combine them.
The node to check. This method will do nothing if the node to
remove is undefined
or null
.
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.
Converts a node to a path.
The node for which to return a path.
The path of the node relative to the root of the tree we are updating.
Converts a path to a node.
The path to convert.
The node corresponding to the path passed.
A complex method. Removes a node from the DOM tree. If two text nodes become adjacent, they are merged.
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.
A location between the two parts that were merged, or between the two nodes that were not merged (because they were not both text).
A complex method. Removes a node from the DOM tree. If two text nodes become adjacent, they are merged.
The node to remove. This method will do nothing if the node to
remove is undefined
or null
.
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.
A complex method. Removes a list of nodes from the DOM tree. If two text nodes become adjacent, they are merged.
These nodes must be immediately contiguous siblings in document order.
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.
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.
The node to modify.
The name of the attribute to modify.
The value to give to the attribute.
A primitive method. Sets an attribute to a value. Setting to the value
null
or undefined
deletes the attribute.
The node to modify.
The URI of the namespace of the attribute.
The name of the attribute to modify.
The value to give to the attribute.
A complex method. Sets a text node to a specified value.
The node to modify.
The new value of the node.
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.
The node to modify. Must be a text node.
The new value of the node.
A complex method. Splits a DOM tree into two halves.
The node at which the splitting operation should end. This node will be split but the function won't split anything above this node.
The location where to start the split.
An array containing in order the first and second half of the split.
Generated using TypeDoc
A TreeUpdater is meant to serve as the sole point of modification for a DOM tree. As methods are invoked on the TreeUpdater to modify the tree, events are issued synchronously, which allows a listener to know what is happening on the tree.
Methods are divided into primitive and complex methods. Primitive methods perform one and only one modification and issue an event of the same name as their own name. Complex methods use primitive methods to perform a series of modifications on the tree. Or they delegate the actual modification work to the primitive methods. They may emit one or more events of a name different from their own name. Events are emitted after their corresponding operation is performed on the tree.
For primitive methods, the list of events which they are documented to be firing is exhaustive. For complex methods, the list is not exhaustive.
Many events have a name identical to a corresponding method. Such events are accompanied by event objects which have the same properties as the parameters of the corresponding method, with the same meaning. Therefore, their properties are not further documented.
There is a generic ChangedEvent that is emitted with every other event. This event does not carry information about what changed exactly.
The TreeUpdater.deleteNode operation is the one major exception to the basic rules given above:
BeforeDeleteNodeEvent is emitted before the deletion is performed. This allows performing operations based on the node's location before it is removed. For instance, calling the DOM method
matches
on a node that has been removed from its DOM tree is generally going to fail to perform the intended check.DeleteNodeEvent has the additional
formerParent
property.DocumentFragment
have special handling. Although the methods below that insert new content into the tree acceptDocumentFragment
nodes, the tree updater inserts the contents of the fragment rather than the fragment itself. Or to put it differently, inserting a fragment is equivalent to iterating through the fragment's children and inserting each one in order. A fragment is essentially equivalent to an array.