hyper-dom-expressions 0.33.2 → 0.33.5

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.
@@ -1,3 +1,12 @@
1
+ const $ELEMENT = Symbol("hyper-element");
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
+
1
10
  // Inspired by https://github.com/hyperhype/hyperscript
2
11
  function createHyperScript(r) {
3
12
  function h() {
@@ -5,6 +14,14 @@ function createHyperScript(r) {
5
14
  e,
6
15
  multiExpression = false;
7
16
 
17
+ typeof args[0] === "string" && detectMultiExpression(args);
18
+ const ret = () => {
19
+ while (args.length) item(args.shift());
20
+ return e;
21
+ };
22
+ ret[$ELEMENT] = true;
23
+ return ret;
24
+
8
25
  function item(l) {
9
26
  const type = typeof l;
10
27
  if (l == null) ;else
@@ -49,17 +66,26 @@ function createHyperScript(r) {
49
66
  }
50
67
  const d = Object.getOwnPropertyDescriptors(props);
51
68
  for (const k in d) {
52
- if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
69
+ if (Array.isArray(d[k].value)) {
70
+ const list = d[k].value;
71
+ props[k] = () => {
72
+ for (let i = 0; i < list.length; i++) {
73
+ while (list[i][$ELEMENT]) list[i] = list[i]();
74
+ }
75
+ return list;
76
+ };
77
+ r.dynamicProperty(props, k);
78
+ } else if (typeof d[k].value === "function" && !d[k].value.length)
79
+ r.dynamicProperty(props, k);
53
80
  }
54
81
  e = r.createComponent(l, props);
55
82
  args = [];
56
- } else r.insert(e, l, multiExpression ? null : undefined);
83
+ } else {
84
+ while (l[$ELEMENT]) l = l();
85
+ r.insert(e, l, multiExpression ? null : undefined);
86
+ }
57
87
  }
58
88
  }
59
- typeof args[0] === "string" && detectMultiExpression(args);
60
- while (args.length) item(args.shift());
61
- return e;
62
-
63
89
  function parseClass(string) {
64
90
  // Our minimal parser doesn’t understand escaping CSS special
65
91
  // characters like `#`. Don’t use them. More reading:
@@ -2,6 +2,15 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ const $ELEMENT = Symbol("hyper-element");
6
+
7
+
8
+
9
+
10
+
11
+
12
+
13
+
5
14
  // Inspired by https://github.com/hyperhype/hyperscript
6
15
  function createHyperScript(r) {
7
16
  function h() {
@@ -9,6 +18,14 @@ function createHyperScript(r) {
9
18
  e,
10
19
  multiExpression = false;
11
20
 
21
+ typeof args[0] === "string" && detectMultiExpression(args);
22
+ const ret = () => {
23
+ while (args.length) item(args.shift());
24
+ return e;
25
+ };
26
+ ret[$ELEMENT] = true;
27
+ return ret;
28
+
12
29
  function item(l) {
13
30
  const type = typeof l;
14
31
  if (l == null) ;else
@@ -53,17 +70,26 @@ function createHyperScript(r) {
53
70
  }
54
71
  const d = Object.getOwnPropertyDescriptors(props);
55
72
  for (const k in d) {
56
- if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
73
+ if (Array.isArray(d[k].value)) {
74
+ const list = d[k].value;
75
+ props[k] = () => {
76
+ for (let i = 0; i < list.length; i++) {
77
+ while (list[i][$ELEMENT]) list[i] = list[i]();
78
+ }
79
+ return list;
80
+ };
81
+ r.dynamicProperty(props, k);
82
+ } else if (typeof d[k].value === "function" && !d[k].value.length)
83
+ r.dynamicProperty(props, k);
57
84
  }
58
85
  e = r.createComponent(l, props);
59
86
  args = [];
60
- } else r.insert(e, l, multiExpression ? null : undefined);
87
+ } else {
88
+ while (l[$ELEMENT]) l = l();
89
+ r.insert(e, l, multiExpression ? null : undefined);
90
+ }
61
91
  }
62
92
  }
63
- typeof args[0] === "string" && detectMultiExpression(args);
64
- while (args.length) item(args.shift());
65
- return e;
66
-
67
93
  function parseClass(string) {
68
94
  // Our minimal parser doesn’t understand escaping CSS special
69
95
  // characters like `#`. Don’t use them. More reading:
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hyper-dom-expressions",
3
3
  "description": "A Fine-Grained Rendering Runtime API using HyperScript",
4
- "version": "0.33.2",
4
+ "version": "0.33.5",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -18,7 +18,7 @@
18
18
  "test:coverage": "npm run build && jest --coverage"
19
19
  },
20
20
  "devDependencies": {
21
- "dom-expressions": "^0.33.2"
21
+ "dom-expressions": "^0.33.5"
22
22
  },
23
- "gitHead": "05fffe9d325238d9be374efa0cccd0ab77d03a31"
23
+ "gitHead": "cb3be7558c731e2a442e9c7e07d25373c40cf2be"
24
24
  }
package/types/index.d.ts CHANGED
@@ -11,7 +11,7 @@ declare type ExpandableNode = Node & {
11
11
  [key: string]: any;
12
12
  };
13
13
  export declare type HyperScript = {
14
- (...args: any[]): ExpandableNode | ExpandableNode[];
14
+ (...args: any[]): () => ExpandableNode | ExpandableNode[];
15
15
  };
16
16
  export declare function createHyperScript(r: Runtime): HyperScript;
17
17
  export {};