@thi.ng/rdom 1.1.10 → 1.1.11
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/CHANGELOG.md +1 -1
- package/compile.d.ts +9 -0
- package/package.json +2 -2
- package/wrap.d.ts +30 -0
package/CHANGELOG.md
CHANGED
package/compile.d.ts
CHANGED
|
@@ -20,6 +20,15 @@ import type { IComponent } from "./api.js";
|
|
|
20
20
|
* target attribute. If used as element body, the reactive value will be wrapped
|
|
21
21
|
* using a {@link $sub} `<span>` with the value as its reactive body.
|
|
22
22
|
*
|
|
23
|
+
* **Important:** Use {@link $replace}, {@link $refresh} or {@link $switch} to
|
|
24
|
+
* wrap any reactive values/subscriptions which produce actual HTML
|
|
25
|
+
* elements/components/subtrees (in hiccup format). See docs for these functions
|
|
26
|
+
* for details & examples. Not using any of these wrappers will result in
|
|
27
|
+
* unexpected outcomes.
|
|
28
|
+
*
|
|
29
|
+
* Also see {@link $wrapText}, {@link $wrapHtml} or {@link $wrapEl} for DOM
|
|
30
|
+
* element related component wrappers.
|
|
31
|
+
*
|
|
23
32
|
* @param tree -
|
|
24
33
|
*/
|
|
25
34
|
export declare const $compile: (tree: any) => IComponent;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thi.ng/rdom",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "Lightweight, reactive, VDOM-less UI/DOM components with async lifecycle and @thi.ng/hiccup compatible",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -142,5 +142,5 @@
|
|
|
142
142
|
],
|
|
143
143
|
"year": 2020
|
|
144
144
|
},
|
|
145
|
-
"gitHead": "
|
|
145
|
+
"gitHead": "f6bb0e172c5dcb574b961f5155a50040d5569685\n"
|
|
146
146
|
}
|
package/wrap.d.ts
CHANGED
|
@@ -12,6 +12,25 @@ export declare const $wrapText: (tag: string, attribs?: any, body?: any) => IMou
|
|
|
12
12
|
* Returns a component wrapper for a single DOM element whose HTML body can be
|
|
13
13
|
* later updated/replaced via `.update()`, similarly to setting `.innerHTML`.
|
|
14
14
|
*
|
|
15
|
+
* @remarks
|
|
16
|
+
* Setting `.innerHtml` considered dangerous — please use with caution or use
|
|
17
|
+
* {@link $wrapText} if the source of the HTML body given to `.update()` cannot
|
|
18
|
+
* be trusted!
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { $compile, $wrapHtml } from "@thi.ng/rdom";
|
|
23
|
+
*
|
|
24
|
+
* // create pre-configured updatable element
|
|
25
|
+
* const title = $wrapHtml("h1", { style: { color: "red" } });
|
|
26
|
+
*
|
|
27
|
+
* // embed inside rdom tree
|
|
28
|
+
* $compile(["div", {}, title, "world..."]).mount(document.body);
|
|
29
|
+
*
|
|
30
|
+
* // update element body (only after element has been mounted!)
|
|
31
|
+
* title.update("<em>hello</em>");
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
15
34
|
* @param tag - element name
|
|
16
35
|
* @param attribs - element attribs
|
|
17
36
|
* @param body - optional initial body
|
|
@@ -21,6 +40,17 @@ export declare const $wrapHtml: (tag: string, attribs?: any, body?: import("@thi
|
|
|
21
40
|
* {@link IComponent} wrapper for an existing DOM element. When mounted, the
|
|
22
41
|
* given element will be (re)attached to the parent node provided at that time.
|
|
23
42
|
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { $compile, $wrapEl } from "@thi.ng/rdom";
|
|
46
|
+
*
|
|
47
|
+
* const title = document.createElement("h1");
|
|
48
|
+
* title.innerText = "hello";
|
|
49
|
+
*
|
|
50
|
+
* // embed existing DOM element inside an rdom tree
|
|
51
|
+
* $compile(["div", {}, $wrapEl(title), "world..."]).mount(document.body);
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
24
54
|
* @param el
|
|
25
55
|
*/
|
|
26
56
|
export declare const $wrapEl: (el: Element) => IComponent;
|