Skip to content

@serenity-is/corelib / attrEncode

Variable: attrEncode()

const attrEncode: (s) => string = htmlEncode

Defined in: src/compat/html-compat.ts:31

Legacy alias for htmlEncode.

HTML-encodes a value by escaping <, >, ", ', and &.

Parameters

s

any

Value to encode. Non-string values are coerced to string; null/undefined yields an empty string.

Returns

string

The HTML-escaped string, safe for interpolation into HTML markup.

Example

htmlEncode('<a href="x">a & b</a>'); // "&lt;a href=&quot;x&quot;&gt;a &amp; b&lt;/a&gt;"

Deprecated

Use htmlEncode directly (it also encodes quotes). Retained as Q.attrEncode compat shim.

See

htmlEncode