The HTML DOM Converter is dedicated to XML grammars, that are closely related to HTML. Typically, the counterpart offers a subset of elements and attributes compared to HTML.

This is an important restriction regarding DOM transformation, as some candy during transformation only comes for HTML elements, such as access to classList or style attributes. Any class attribute of a custom namespace requires to be parsed manually (at least, if it has a namespace prefix).

Constructors

Properties

Methods

Constructors

Properties

Context for conversion.

logger?: Logger

Methods

  • Converts the given node and its children to the target document. The processing is performed in this order:

    1. imported: Node is imported into the current document, possibly transforming default namespace towards the new document default. In post-processing, the imported node may be replaced by a new node.
    2. post-process imported: An optional post-processing may now replace the given node.
    3. finish: In the end, node conversion is finished, providing a last option for transforming a node and even removing it.

    Parameters

    • originalNode: Node

      node to convert

    Returns undefined | Node

    the imported, not yet attached, node along with converted child nodes; undefined if the node is to be ignored in the target document.

  • Converts the given original node via convert and subsequently appends the result to targetParentNode. Different to convert this ensures that appended handler is also called when appending to target parent node.

    Parameters

    • originalNode: Node

      original node to transform

    • targetParentNode: ParentNode

      node in target document where to append the conversion result to.

    Returns void