@solidjs/h 2.0.0-experimental.5 → 2.0.0-experimental.6

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.
Files changed (3) hide show
  1. package/dist/h.cjs +7 -24
  2. package/dist/h.js +7 -24
  3. package/package.json +3 -3
package/dist/h.cjs CHANGED
@@ -2,23 +2,12 @@
2
2
 
3
3
  var web = require('@solidjs/web');
4
4
 
5
- const $ELEMENT = Symbol("hyper-element");
6
5
  function createHyperScript(r) {
7
6
  function h() {
8
7
  let args = [].slice.call(arguments),
9
8
  e,
10
9
  classes = [],
11
10
  multiExpression = false;
12
- while (Array.isArray(args[0])) args = args[0];
13
- if (args[0][$ELEMENT]) args.unshift(h.Fragment);
14
- typeof args[0] === "string" && detectMultiExpression(args);
15
- const ret = () => {
16
- while (args.length) item(args.shift());
17
- if (e instanceof Element && classes.length) e.classList.add(...classes);
18
- return e;
19
- };
20
- ret[$ELEMENT] = true;
21
- return ret;
22
11
  function item(l) {
23
12
  const type = typeof l;
24
13
  if (l == null) ;else if ("string" === type) {
@@ -34,8 +23,7 @@ function createHyperScript(r) {
34
23
  const d = Object.getOwnPropertyDescriptors(l);
35
24
  for (const k in d) {
36
25
  if (k === "class" && classes.length !== 0) {
37
- const fixedClasses = classes.join(" "),
38
- value = typeof d["class"].value === "function" ? () => fixedClasses + " " + d["class"].value() : fixedClasses + " " + l["class"];
26
+ const value = typeof d["class"].value === "function" ? () => [...classes, d["class"].value()] : [...classes, l["class"]];
39
27
  Object.defineProperty(l, "class", {
40
28
  ...d[k],
41
29
  value
@@ -59,25 +47,20 @@ function createHyperScript(r) {
59
47
  }
60
48
  const d = Object.getOwnPropertyDescriptors(props);
61
49
  for (const k in d) {
62
- if (Array.isArray(d[k].value)) {
63
- const list = d[k].value;
64
- props[k] = () => {
65
- for (let i = 0; i < list.length; i++) {
66
- while (list[i][$ELEMENT]) list[i] = list[i]();
67
- }
68
- return list;
69
- };
70
- r.dynamicProperty(props, k);
71
- } else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
50
+ if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
72
51
  }
73
52
  e = r.createComponent(l, props);
74
53
  args = [];
75
54
  } else {
76
- while (l[$ELEMENT]) l = l();
77
55
  r.insert(e, l, multiExpression ? null : undefined);
78
56
  }
79
57
  }
80
58
  }
59
+ if (args.length === 1 && Array.isArray(args[0])) return args[0];
60
+ typeof args[0] === "string" && detectMultiExpression(args);
61
+ while (args.length) item(args.shift());
62
+ if (e instanceof Element && classes.length) e.classList.add(...classes);
63
+ return e;
81
64
  function parseClass(string) {
82
65
  const m = string.split(/([\.#]?[^\s#.]+)/);
83
66
  if (/^\.|#/.test(m[1])) e = document.createElement("div");
package/dist/h.js CHANGED
@@ -1,22 +1,11 @@
1
1
  import { spread, assign, insert, createComponent, dynamicProperty, SVGElements } from '@solidjs/web';
2
2
 
3
- const $ELEMENT = Symbol("hyper-element");
4
3
  function createHyperScript(r) {
5
4
  function h() {
6
5
  let args = [].slice.call(arguments),
7
6
  e,
8
7
  classes = [],
9
8
  multiExpression = false;
10
- while (Array.isArray(args[0])) args = args[0];
11
- if (args[0][$ELEMENT]) args.unshift(h.Fragment);
12
- typeof args[0] === "string" && detectMultiExpression(args);
13
- const ret = () => {
14
- while (args.length) item(args.shift());
15
- if (e instanceof Element && classes.length) e.classList.add(...classes);
16
- return e;
17
- };
18
- ret[$ELEMENT] = true;
19
- return ret;
20
9
  function item(l) {
21
10
  const type = typeof l;
22
11
  if (l == null) ;else if ("string" === type) {
@@ -32,8 +21,7 @@ function createHyperScript(r) {
32
21
  const d = Object.getOwnPropertyDescriptors(l);
33
22
  for (const k in d) {
34
23
  if (k === "class" && classes.length !== 0) {
35
- const fixedClasses = classes.join(" "),
36
- value = typeof d["class"].value === "function" ? () => fixedClasses + " " + d["class"].value() : fixedClasses + " " + l["class"];
24
+ const value = typeof d["class"].value === "function" ? () => [...classes, d["class"].value()] : [...classes, l["class"]];
37
25
  Object.defineProperty(l, "class", {
38
26
  ...d[k],
39
27
  value
@@ -57,25 +45,20 @@ function createHyperScript(r) {
57
45
  }
58
46
  const d = Object.getOwnPropertyDescriptors(props);
59
47
  for (const k in d) {
60
- if (Array.isArray(d[k].value)) {
61
- const list = d[k].value;
62
- props[k] = () => {
63
- for (let i = 0; i < list.length; i++) {
64
- while (list[i][$ELEMENT]) list[i] = list[i]();
65
- }
66
- return list;
67
- };
68
- r.dynamicProperty(props, k);
69
- } else if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
48
+ if (typeof d[k].value === "function" && !d[k].value.length) r.dynamicProperty(props, k);
70
49
  }
71
50
  e = r.createComponent(l, props);
72
51
  args = [];
73
52
  } else {
74
- while (l[$ELEMENT]) l = l();
75
53
  r.insert(e, l, multiExpression ? null : undefined);
76
54
  }
77
55
  }
78
56
  }
57
+ if (args.length === 1 && Array.isArray(args[0])) return args[0];
58
+ typeof args[0] === "string" && detectMultiExpression(args);
59
+ while (args.length) item(args.shift());
60
+ if (e instanceof Element && classes.length) e.classList.add(...classes);
61
+ return e;
79
62
  function parseClass(string) {
80
63
  const m = string.split(/([\.#]?[^\s#.]+)/);
81
64
  if (/^\.|#/.test(m[1])) e = document.createElement("div");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@solidjs/h",
3
3
  "description": "A standard (less-optimal) JSX factory for Solid",
4
- "version": "2.0.0-experimental.5",
4
+ "version": "2.0.0-experimental.6",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -46,10 +46,10 @@
46
46
  "./types/*": "./types/*"
47
47
  },
48
48
  "peerDependencies": {
49
- "@solidjs/web": "^2.0.0-experimental.5"
49
+ "@solidjs/web": "^2.0.0-experimental.6"
50
50
  },
51
51
  "devDependencies": {
52
- "@solidjs/web": "2.0.0-experimental.5"
52
+ "@solidjs/web": "2.0.0-experimental.6"
53
53
  },
54
54
  "scripts": {
55
55
  "build": "npm-run-all -nl build:*",