@tixyel/streamelements 7.7.0 → 7.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +12 -0
- package/dist/index.es.js +10 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2503,6 +2503,18 @@ declare class ElementHelper {
|
|
|
2503
2503
|
* ```
|
|
2504
2504
|
*/
|
|
2505
2505
|
CSS(element: HTMLElement | SVGElement, styles: Partial<Record<keyof CSSStyleProperties | `--${string}`, CSSValue>>): void;
|
|
2506
|
+
/**
|
|
2507
|
+
* Escapes special HTML characters in a string to prevent XSS attacks and ensure safe rendering in HTML contexts.
|
|
2508
|
+
* @param value - The input string that may contain special HTML characters such as &, <, >, ", and '.
|
|
2509
|
+
* @returns A new string with special HTML characters replaced by their corresponding HTML entities.
|
|
2510
|
+
* @example
|
|
2511
|
+
* ```javascript
|
|
2512
|
+
* const unsafeString = '<script>alert("XSS")</script>';
|
|
2513
|
+
* const safeString = escapeHtml(unsafeString);
|
|
2514
|
+
* console.log(safeString); // Output: '<script>alert("XSS")</script>'
|
|
2515
|
+
* ```
|
|
2516
|
+
*/
|
|
2517
|
+
escapeHtml(value: string): string;
|
|
2506
2518
|
}
|
|
2507
2519
|
type CSSValue = string | number | null | undefined;
|
|
2508
2520
|
|
package/dist/index.es.js
CHANGED
|
@@ -254,6 +254,16 @@ var e = Object.defineProperty, t = (t, n) => {
|
|
|
254
254
|
e.style.setProperty(t, a);
|
|
255
255
|
}
|
|
256
256
|
}
|
|
257
|
+
escapeHtml(e) {
|
|
258
|
+
let t = {
|
|
259
|
+
"&": "&",
|
|
260
|
+
"<": "<",
|
|
261
|
+
">": ">",
|
|
262
|
+
"\"": """,
|
|
263
|
+
"'": "'"
|
|
264
|
+
};
|
|
265
|
+
return e.replace(/[&<>"']/g, (e) => t[e]);
|
|
266
|
+
}
|
|
257
267
|
}, i = class {
|
|
258
268
|
flatten(e, t = !0, n = "") {
|
|
259
269
|
let r = {};
|