import{_ as t,o as i,c as a,ae as e}from"./chunks/framework.C8AWLET_.js";const k=JSON.parse('{"title":"๐Ÿ—๏ธ The DOM Factory: $html( )","description":"","frontmatter":{},"headers":[],"relativePath":"api/html.md","filePath":"api/html.md"}'),n={name:"api/html.md"};function l(h,s,r,o,p,d){return i(),a("div",null,[...s[0]||(s[0]=[e(`

๐Ÿ—๏ธ The DOM Factory: $html( ) โ€‹

$html is the internal engine that creates, attributes, and attaches reactivity to DOM elements. It uses $.watch to maintain a live, high-performance link between your Signals and the Document Object Model.

๐Ÿ›  Function Signature โ€‹

typescript
$html(tagName: string, props?: Object, children?: any[] | any): HTMLElement
ParameterTypeRequiredDescription
tagNamestringYesValid HTML tag name (e.g., "div", "button").
propsObjectNoHTML attributes, event listeners, and reactive bindings.
childrenanyNoNested elements, text strings, or reactive functions.

๐Ÿ“– Key Features โ€‹

1. Attribute Handling โ€‹

SigPro intelligently decides how to apply each property:

2. Event Listeners โ€‹

Events are defined by the on prefix. SigPro automatically registers the listener and ensures it is cleaned up when the element is destroyed.

javascript
Button({
  onclick: (e) => console.log("Clicked!", e),
}, "Click Me");

3. Reactive Attributes (One-Way) โ€‹

If an attribute value is a function (like a Signal), $html creates an internal $.watch to keep the DOM in sync with the state.

javascript
Div({
  // Updates the class whenever 'theme()' changes
  class: () => theme() === "dark" ? "bg-black" : "bg-white"
});

4. Smart Two-Way Binding (Automatic) โ€‹

SigPro automatically enables bidirectional synchronization when it detects a Signal assigned to a form-capable attribute (value or checked) on an input element (input, textarea, select).

javascript
// Syncs input value <-> signal automatically
Input({ 
  type: "text", 
  value: username // No special symbols needed!
})

Note: To use a Signal as read-only in an input, wrap it in an anonymous function: value: () => username().

5. Reactive Children โ€‹

Children can be static or dynamic. When a child is a function, SigPro creates a reactive boundary using $.watch for that specific part of the DOM.

javascript
Div({}, [
  H1("Static Title"),
  // Only this text node re-renders when 'count' changes
  () => \`Current count: \${count()}\`
]);

๐Ÿงน Memory Management (Internal) โ€‹

Every element created with $html is "self-aware" regarding its reactive dependencies.


๐Ÿ’ก Tag Constructors (The Shortcuts) โ€‹

Instead of writing $html("div", ...) every time, SigPro provides PascalCase global functions for all standard HTML tags:

javascript
// This:
Div({ class: "wrapper" }, [ Span("Hello") ])

// Is exactly equivalent to:
$html("div", { class: "wrapper" }, [ $html("span", {}, "Hello") ])
`,31)])])}const g=t(n,[["render",l]]);export{k as __pageData,g as default};