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
Name | Type | Description |
---|---|---|
fiber | StaticFiber | The fiber to create a DOM element for. |
Returns
Text
| HTMLElement
The created DOM node, either a Text or a HTMLElement.
Defined in
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
Name | Type | Description |
---|---|---|
domNode | HTMLElement | Text | The DOM node whose property should be updated. |
previousProps | Props | The props of the previous version. These will be removed. |
currentProps | Props | The props of the current version. These will be added. |
Returns
void