UseSetHtml
katanakit-js / useSetHtml
Function: useSetHtml()
Section titled “Function: useSetHtml()”function useSetHtml(target, html): void;Defined in: infrastructure/dom/dom.service.ts:421
Sets innerHTML on the target element.
XSS risk: this is an HTML injection sink. Never pass unsanitized user input. Prefer useSetText for plain text, or sanitize with a trusted library (e.g. DOMPurify) before calling this function.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
target |
string | Element |
A CSS selector string or an Element instance. |
html |
string |
The HTML string to set. |
Returns
Section titled “Returns”void
Example
Section titled “Example”// Safe — trusted static markupuseSetHtml("#banner", "<strong>Hello</strong>");
// Unsafe — do NOT do this with user content// useSetHtml("#out", userInput);