Skip to content

UseSetHtml

katanakit-js / 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.

Parameter Type Description
target string | Element A CSS selector string or an Element instance.
html string The HTML string to set.

void

// Safe — trusted static markup
useSetHtml("#banner", "<strong>Hello</strong>");
// Unsafe — do NOT do this with user content
// useSetHtml("#out", userInput);