@@ -37,6 +37,25 @@ export const $wrapText = wrapper($text);
3737 * Returns a component wrapper for a single DOM element whose HTML body can be
3838 * later updated/replaced via `.update()`, similarly to setting `.innerHTML`.
3939 *
40+ * @remarks
41+ * Setting `.innerHtml` considered dangerous — please use with caution or use
42+ * {@link $wrapText} if the source of the HTML body given to `.update()` cannot
43+ * be trusted!
44+ *
45+ * @example
46+ * ```ts
47+ * import { $compile, $wrapHtml } from "@thi.ng/rdom";
48+ *
49+ * // create pre-configured updatable element
50+ * const title = $wrapHtml("h1", { style: { color: "red" } });
51+ *
52+ * // embed inside rdom tree
53+ * $compile(["div", {}, title, "world..."]).mount(document.body);
54+ *
55+ * // update element body (only after element has been mounted!)
56+ * title.update("<em>hello</em>");
57+ * ```
58+ *
4059 * @param tag - element name
4160 * @param attribs - element attribs
4261 * @param body - optional initial body
@@ -47,6 +66,17 @@ export const $wrapHtml = wrapper($html);
4766 * {@link IComponent } wrapper for an existing DOM element. When mounted, the
4867 * given element will be (re)attached to the parent node provided at that time.
4968 *
69+ * @example
70+ * ```ts
71+ * import { $compile, $wrapEl } from "@thi.ng/rdom";
72+ *
73+ * const title = document.createElement("h1");
74+ * title.innerText = "hello";
75+ *
76+ * // embed existing DOM element inside an rdom tree
77+ * $compile(["div", {}, $wrapEl(title), "world..."]).mount(document.body);
78+ * ```
79+ *
5080 * @param el
5181 */
5282export const $wrapEl = ( el : Element ) : IComponent => ( {
0 commit comments