v0.20.230 - 7.2 / 5.9

setProperty

Imperative helper for assigning a DOM property on an element. Unwraps reactive accessors; assigning null or undefined sets the property to null.

# Signature

# Arguments

nametypedescription
nodeElementtarget element
namestringproperty name on the DOM node
valueunknown | signalvalue to assign. Functions are unwrapped reactively. null / undefined set the property to null.

Returns: void

# When to use

Use setProperty (or the prop: namespace in JSX) whenever the DOM property and HTML attribute diverge — value on inputs after user edits, checked state, srcObject on video, textContent, or custom properties on a custom element.

# Snippet