count="${0}" count "0" prop:count="${0}" count 0
const const MyElement = customElement(() => {
return html`<my-counter prop:count="${0}"></my-counter>`;
});
PLEASE NOTE: While HTML does not natively support uppercase characters in attributes, Thunderous supports camelCase for properties. For example,(invalid icon)
prop:myCount="${0}" myCount 0 myElement.count = 1
const MyElement = customElement<{ count: number }>(({ propSignals }) => {
// The signal and property are defined automatically when the proxy is accessed
const [count, setCount] = propSignals.count;
setCount(0);
// As of v2.2.0, you can also initialize the signal immediately
const [count, setCount] = propSignals.count.init(0);
// setCount() will also update the DOM property,
// eg. `document.querySelector('my-element').count`
return html`<output>${count}</output>`;
});
customElement Signal<unknown>NOTICE: The signal's getter will throw an error at runtime if the property is accessed before its value is initialized. You must either set the property before the signal is accessed or call(invalid icon)
init() attributesAsProperties [attributeName, coerceFunction] ['count', Number]PLEASE NOTE: Kebab case converts to camelCase, so(invalid icon)
['my-count', Number] propSignals.myCount
const MyElement = customElement<{ count: number }>(({ propSignals }) => {
const [count, setCount] = propSignals.count.init(0);
// setCount() will update both the DOM property, AND the HTML attribute.
return html`<output>${count}</output>`;
}, { attributesAsProperties: [['count', Number]] });
count
<my-element count="1"></my-element>
const myElement = document.querySelector('my-element');
myElement.count = 1;
count()