libxmljs2
libxmljs2 copied to clipboard
Method "insertBefore" on Element
On the element there should be a method to insert a new node at a reference within an element. Currently, for example, there is no possibility to insert a node in front of a processing instruction.
Example:
export class Element extends Node {
// ...
/**
* @param {Node} node
* Node to insert in front of the passed `reference`
* @param {Node | null} reference
* Reference to insert the node. When passing `null` the node will be appended to `this` element.
* The passed node has to be a child of this element.
* @return The original element, not the child.
*/
insertBefore(node: Node, reference: Node | null): this;
}
May the Node has to be ProcessingInstruction | Text | Element | Comment | null - Otherwise you could try to insert something in front of an Attribute
Usage:
const address = document.get('/address')
const name = address.get('/name');
const marker = address.get('./processing-instruction("marker")');
address.insertBefore(name, marker);