Skip to content
0

katanakit-js / useSetHtml

Function: useSetHtml() ​

ts
function useSetHtml(target, html): void;

Defined in: src/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 ​

ParameterTypeDescription
targetstring | ElementA CSS selector string or an Element instance.
htmlstringThe HTML string to set.

Returns ​

void

Example ​

ts
// Safe — trusted static markup
useSetHtml("#banner", "<strong>Hello</strong>");

// Unsafe — do NOT do this with user content
// useSetHtml("#out", userInput);

Released under the MIT License.