v0.16.163 - 32.6 / 23.1

attributes / properties

Describes behavior with attributes and properties.

# Attributes vs Properties

setProperty will be used when any of the following is true:

  1. tagName has a dash (as custom-elements do) and propName is a setter
  2. the value is different than string and element has a propName setter

While this does not work for every situation, it's a sensible default that works in most cases. To change this behavior see the next section

# Namespace To Force Props Type

A namespace can be used to force the prop kind

NameKindDescription
attr:namesetAttributewill always add it as an attribute
prop:namesetPropertywill always set it as a property
bool:namesetBooladds/remove based on truthy/falsy

# Deleting

On a property, deleting means setting the value to null when the new value is null or undefined.

On an attribute, deleting means removing the attribute when the new value is null or undefined.

# Children

children as an attribute will be used as long as the node on where it's defined doesn't have any childNodes.

# xmlns

The xmlns attribute is copied to children. Which means it supports by default most kinds if not all xmls: SVG, MathML, with its fancy namespaces.

# Events

Events using the on__ form are case insensitive

Events using the on:__ form are case sensitive

# Props With Default Behavior

NameDescription
refcallback to get a reference to the element
onMountonMount adds a callback to the mount event
onUnmountonUnmount adds a callback to the unmount event
classsets classes in the element in various ways
stylesets styles in the element in various ways
varsets a css var in the element
css<span css="class{color:green} class:hover{color:red}"/> becomes <span class="class-styles-applied"/>

# SVG

test: SVG + xlink

# Showing XML Test

Testing if keeps the parent xmlns using a toggling Show