@davidcal/frosth 1.0.0 → 1.0.2

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/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Frosth - Yet another UI framework
2
2
 
3
+ **Latest version**: v1.0.2
4
+
3
5
  ## Motivation
4
6
 
5
7
  Frontend component frameworks are still a mess (controversial, I know).
@@ -261,3 +263,15 @@ const App = obtain(async ({ t, s }) => {
261
263
  ]);
262
264
  });
263
265
  ```
266
+
267
+ Ensure to wrap children in an array if making it reactive, or alternatively pass in a component instance that is inherently reactive.
268
+
269
+ ```
270
+ const my_text_constant = create_signal(() => "my text content");
271
+
272
+ installed.set(() => [
273
+ (s) => s.$h1({}, [
274
+ (s) => my_text_content(s),
275
+ ]),
276
+ ])
277
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@davidcal/frosth",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Async-first CRUD-last UI framework that treats encapsulation as a solved problem.",
5
5
  "type": "module",
6
6
  "main": "./src/sigew.js",
@@ -33,7 +33,22 @@ class Fragment {
33
33
 
34
34
  set innerText(text) {
35
35
  this.clear();
36
- this.appendChild(document.createTextNode(text));
36
+
37
+ if (text === null || text === undefined) {
38
+ return;
39
+ }
40
+
41
+ this.appendChild(document.createTextNode(String(text)));
42
+ }
43
+
44
+ set textContent(text) {
45
+ this.clear();
46
+
47
+ if (text === null || text === undefined) {
48
+ return;
49
+ }
50
+
51
+ this.appendChild(document.createTextNode(String(text)));
37
52
  }
38
53
  }
39
54
 
@@ -21,6 +21,10 @@ class Self {
21
21
  }
22
22
  }
23
23
 
24
+ _create_child(run_effect, options) {
25
+ return create_self(this, run_effect, options);
26
+ }
27
+
24
28
  create_effect(callback) {
25
29
  let child;
26
30
 
package/src/h.js CHANGED
@@ -31,12 +31,6 @@ export const h = (s, tag, props, children) => {
31
31
  });
32
32
  }
33
33
  }
34
-
35
- if (typeof children === "string") {
36
- el.textContent = children;
37
-
38
- return el;
39
- }
40
34
 
41
35
  if (children !== undefined) {
42
36
  const fragment = create_fragment(el);
package/src/render.js CHANGED
@@ -20,11 +20,13 @@ const render_diff = (s, prev, next, target) => {
20
20
  return prev_map.get(item);
21
21
  }
22
22
 
23
- const item_self = create_self(s);
23
+ const item_self = s._create_child();
24
24
  const fragment = create_fragment(target);
25
25
  const new_state = { prev: [] };
26
26
 
27
- render(item_self, fragment, item(item_self), new_state);
27
+ item_self.create_effect((s) => {
28
+ render(s._create_child(), fragment, item(s), new_state);
29
+ });
28
30
 
29
31
  return { item, item_self, fragment, state: new_state };
30
32
  });
@@ -33,7 +35,13 @@ const render_diff = (s, prev, next, target) => {
33
35
  };
34
36
 
35
37
  export const render = async (s, target, installed, state) => {
36
- console.log("rendering", installed);
38
+ console.log("rendering", installed, typeof installed);
39
+
40
+ if (typeof installed === "string") {
41
+ target.textContent = installed;
42
+
43
+ return;
44
+ }
37
45
 
38
46
  if (Array.isArray(installed)) {
39
47
  if (state.prev.length === 0) {