- A
function
is executed and its return value is subjet to the following rules, dynamic value is configured to be able toupdate
itself in the future and theComponent
is created - A
Component
instance renders itselement
true, false, null, undefined
are converted to empty text nodes to enable logical expressions, ex:isVisible && <ModalDialog />
- Static
Array
values are applied to the element according rules above, including nested arrays - Everything else is converted into a text node
- Dynamic
Array
(returned from a function) updates associated children before the terminator node which is added at the end. Dynamic arrays differ from the static in that they are not creating new components from their functional elements
Nested arrays for added performance benefit of not needing to flatten them and to not recreate multiple arrays objects copies Functions in dynamic arrays are for added benefit of performance and flexibility to create dynamic arrays once and not recreate them when data change is needed
- Property values are applied as-is
"", null, false, undefined
- attribute is removedtrue
- attribute is set to""
- Everything else is converted to string and applied to element as its attributes.
The current DOM value will be updated only if:
- primitive value has changed
- object value reference has changed
Therefore, you should cache referenced values
Do not use $
suffix:
- Set a property if value is of reference type:
Object
,Array
,Function
... (notnull
) - Set a property if it is already exists on the element
- Set an attribute otherwise
Use $
suffix:
a
-a
ttributean
-a
ttributen
amespacedp
-p
ropertyps
-p
ropertys
tatice
-e
vent
is
- custom element namemount
- element connect callback
In functional notation they must be present in the first props object
Use setPropSplitter('_')
to change the global suffix splitter from $
<div
// auto-detect whether to set property or attribute
id="abc"
class="visible"
style="color:red"
selected={123}
// property
checked$p={456}
// property static
onclick$ps={() => 'Clicked!'}
customFunction$ps={() => 'Custom component function property'}
// attribute
myprop$a="visible"
// attribute with namespace
{...{'xlink:href$an$http://www.w3.org/1999/xlink': 'abc'}}
// bubbling event listener
click$e={() => 'Clicked!'}
// all boolean event options
click$e$capture$once$passive$update={() => 'Clicked!'}
// all event options
click$e={{
handle: () => 'Clicked!', // or handle: {handleEvent: () => 'Clicked!'},
capture: true,
once: true,
passive: true,
signal: abort,
update: true, // update target component after event handler completes
}}
// special props
is="custom-element-name"
mount={(self) => {
self.update();
return () => 'unmount';
}}
/>