DOM Interop
DOM Interop¶
Element is a thin wrapper around DOM nodes with helpers for attributes, classes, events, and querying.
from wybthon.dom import Element
root = Element("#app", existing=True)
div = Element("div")
div.set_text("Hello")
div.append_to(root)
TODO: Explain refs and how VDOM uses
Elementunder the hood.
Styles and dataset via VDOM¶
- Use the
styleprop with a dict of camelCase keys; the VDOM converts to kebab-case and callsstyle.setProperty. Missing keys on update are removed. PassingNoneclears previous styles. - Use the
datasetprop with a dict; entries render asdata-*attributes. Missing keys on update are removed. PassingNoneclears previous dataset entries.