Props
wybthon.props¶
props
¶
DOM property application and diffing for element VNodes.
Translates VNode props into DOM attribute, style, and event mutations, including:
- Controlled form elements (
value,checked) via DOM properties. - CSS style objects (
{"backgroundColor": "red"}→ kebab-cased inline styles). - Dataset attributes (
{"dataset": {"id": 5}}→data-id="5"). - Event delegation for
on_click/onClickstyle handlers. - Reactive prop bindings: callable prop values are wrapped in their own effect so updates re-apply only the affected prop, never the surrounding component.
This module is consumed by the reconciler; most application code never imports from it directly.
Functions:
| Name | Description |
|---|---|
to_kebab |
Convert a camelCase property name to kebab-case. |
is_event_prop |
Return True if |
event_name_from_prop |
Convert an |
attach_ref |
Assign |
detach_ref |
Clear |
apply_props |
Apply prop diffs to a concrete DOM element, including events and styles. |
apply_initial_props |
Apply a fresh set of props on initial mount, wiring reactive bindings. |
to_kebab
¶
is_event_prop
¶
event_name_from_prop
¶
attach_ref
¶
attach_ref(props: PropsDict, el: Element) -> None
Assign el to props["ref"].current when a ref prop is present.
detach_ref
¶
Clear props["ref"].current when a ref prop is present.
apply_props
¶
apply_props(el: Element, old_props: PropsDict, new_props: PropsDict) -> None
Apply prop diffs to a concrete DOM element, including events and styles.
Used by the patch path; both old and new props are static (already-
resolved) values. For initial mount with potentially reactive prop
values, use apply_initial_props.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
el
|
Element
|
The target DOM element wrapper. |
required |
old_props
|
PropsDict
|
Previously-applied prop dict. |
required |
new_props
|
PropsDict
|
Newly-resolved prop dict. |
required |
apply_initial_props
¶
Apply a fresh set of props on initial mount, wiring reactive bindings.
Callable prop values (excluding event handlers and ref) are treated
as reactive bindings: each is wrapped in its own effect so that
updates re-apply only that single prop, with no re-render of the
surrounding component. Static values are applied once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
el
|
Element
|
The target DOM element wrapper. |
required |
new_props
|
PropsDict
|
Initial prop dict. |
required |
owner_vnode
|
Optional[Any]
|
Currently unused. Accepted for forward compatibility with reconciler bookkeeping. |
None
|
What's in this module¶
props contains the prop-level diffing helpers used by the reconciler:
attribute set/remove, class and style merging, event handler updates,
and a few utilities for normalizing prop names (class_ to class,
for_ to for, etc.).
You normally interact with props by passing keyword arguments to tag
helpers in wybthon.html or to h. The
helpers here document the semantics and edge cases.
Reserved prop names¶
| Name | Purpose |
|---|---|
children |
Explicit children list (alternative to positional args). |
key |
Identity hint for keyed list reconciliation. |
ref |
A Ref populated when the underlying element is mounted. |
class_ / className |
Both map to the DOM class attribute. |
for_ / html_for |
Both map to the DOM for attribute. |
on_* |
Event handlers; see events. |
style |
A dict of CSS properties or a string. |
See also¶
vdom: entry points for rendering and patching.events: event delegation details.- Concepts: DOM Interop