Skip to main content

Module: dom

Functions​

createDomNode​

▸ createDomNode(fiber): Text | HTMLElement

Creates a new DOM node for the fiber.

  • For normal elements a HTMLElement with the type of the fiber is created.
  • For a TEXT_NODE a Text is created.
  • For a PLACEHOLDER_NODE the function throws, as it is not possible to create a DOM node for it.

Parameters​

NameTypeDescription
fiberStaticFiberThe fiber to create a DOM element for.

Returns​

Text | HTMLElement

The created DOM node, either a Text or a HTMLElement.

Defined in​

dom.ts:12


updateDomNode​

▸ updateDomNode(domNode, previousProps?, currentProps?): void

Updates the given DOM node with the provided props. The previousProps are removed from the node and the currentProps are added to it. All properties starting with on are treated as event listeners and are added and removed automatically. To support JSX, events are also converted to lowercase e.g., (onClick -> onclick), such that they match the vanilla JS notation. If the given domNode is a Text element, the only updated property is nodeValue.

Parameters​

NameTypeDescription
domNodeHTMLElement | TextThe DOM node whose property should be updated.
previousPropsPropsThe props of the previous version. These will be removed.
currentPropsPropsThe props of the current version. These will be added.

Returns​

void

Defined in​

dom.ts:33