a reactive (signals based) hypermedia web framework (wip) stormlightlabs.github.io/volt/
hypermedia frontend signals
1--- 2version: 1.0 3updated: 2025-10-18 4--- 5 6# dom 7 8DOM utility functions 9 10## walkDOM 11 12Walk the DOM tree and collect all elements with data-volt-* attributes in document order (parent before children). 13 14Skips children of elements with data-volt-for or data-volt-if since those will be processed when the parent element is cloned and mounted. 15 16```typescript 17export function walkDOM(root: Element): Element[] 18``` 19 20## hasVoltAttribute 21 22Check if an element has any data-volt-* attributes. 23 24```typescript 25export function hasVoltAttribute(element: Element): boolean 26``` 27 28## getVoltAttributes 29 30Get all data-volt-\* attributes from an element. 31Excludes charge metadata attributes (state, computed:*) that are processed separately. 32 33```typescript 34export function getVoltAttributes(element: Element): Map<string, string> 35``` 36 37## setText 38 39Set the text content of an element safely. 40 41```typescript 42export function setText(element: Element, value: unknown): void 43``` 44 45## setHTML 46 47Set the HTML content of an element safely. 48Note: This trusts the input HTML and should only be used with sanitized content. 49 50```typescript 51export function setHTML(element: Element, value: string): void 52``` 53 54## toggleClass 55 56Add or remove a CSS class from an element. 57 58```typescript 59export function toggleClass(element: Element, className: string, add: boolean): void 60``` 61 62## parseClassBinding 63 64Parse a class binding expression. 65Supports string values ("active"), object notation ({active: true}), 66and other primitives (true, false, numbers) which are converted to strings. 67 68```typescript 69export function parseClassBinding(value: unknown): Map<string, boolean> 70```