@solidjs/h 2.0.0-experimental.1 → 2.0.0-experimental.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/LICENSE +1 -1
- package/dist/h.js +40 -9
- package/jsx-runtime/dist/jsx.js +1 -1
- package/package.json +2 -3
- package/jsx-runtime/types/index.d.ts +0 -14
- package/jsx-runtime/types/jsx.d.ts +0 -4080
- package/types/hyperscript.d.ts +0 -20
- package/types/index.d.ts +0 -3
package/LICENSE
CHANGED
package/dist/h.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
spread,
|
|
3
|
+
assign,
|
|
4
|
+
insert,
|
|
5
|
+
createComponent,
|
|
6
|
+
dynamicProperty,
|
|
7
|
+
SVGElements
|
|
8
|
+
} from "@solidjs/web";
|
|
2
9
|
|
|
3
10
|
const $ELEMENT = Symbol("hyper-element");
|
|
4
11
|
function createHyperScript(r) {
|
|
@@ -19,9 +26,18 @@ function createHyperScript(r) {
|
|
|
19
26
|
return ret;
|
|
20
27
|
function item(l) {
|
|
21
28
|
const type = typeof l;
|
|
22
|
-
if (l == null)
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
if (l == null);
|
|
30
|
+
else if ("string" === type) {
|
|
31
|
+
if (!e) parseClass(l);
|
|
32
|
+
else e.appendChild(document.createTextNode(l));
|
|
33
|
+
} else if (
|
|
34
|
+
"number" === type ||
|
|
35
|
+
"boolean" === type ||
|
|
36
|
+
"bigint" === type ||
|
|
37
|
+
"symbol" === type ||
|
|
38
|
+
l instanceof Date ||
|
|
39
|
+
l instanceof RegExp
|
|
40
|
+
) {
|
|
25
41
|
e.appendChild(document.createTextNode(l.toString()));
|
|
26
42
|
} else if (Array.isArray(l)) {
|
|
27
43
|
for (let i = 0; i < l.length; i++) item(l[i]);
|
|
@@ -33,7 +49,10 @@ function createHyperScript(r) {
|
|
|
33
49
|
for (const k in d) {
|
|
34
50
|
if (k === "class" && classes.length !== 0) {
|
|
35
51
|
const fixedClasses = classes.join(" "),
|
|
36
|
-
value =
|
|
52
|
+
value =
|
|
53
|
+
typeof d["class"].value === "function"
|
|
54
|
+
? () => fixedClasses + " " + d["class"].value()
|
|
55
|
+
: fixedClasses + " " + l["class"];
|
|
37
56
|
Object.defineProperty(l, "class", {
|
|
38
57
|
...d[k],
|
|
39
58
|
value
|
|
@@ -45,12 +64,18 @@ function createHyperScript(r) {
|
|
|
45
64
|
dynamic = true;
|
|
46
65
|
} else if (d[k].get) dynamic = true;
|
|
47
66
|
}
|
|
48
|
-
dynamic
|
|
67
|
+
dynamic
|
|
68
|
+
? r.spread(e, l, e instanceof SVGElement, !!args.length)
|
|
69
|
+
: r.assign(e, l, e instanceof SVGElement, !!args.length);
|
|
49
70
|
} else if ("function" === type) {
|
|
50
71
|
if (!e) {
|
|
51
72
|
let props,
|
|
52
73
|
next = args[0];
|
|
53
|
-
if (
|
|
74
|
+
if (
|
|
75
|
+
next == null ||
|
|
76
|
+
(typeof next === "object" && !Array.isArray(next) && !(next instanceof Element))
|
|
77
|
+
)
|
|
78
|
+
props = args.shift();
|
|
54
79
|
props || (props = {});
|
|
55
80
|
if (args.length) {
|
|
56
81
|
props.children = args.length > 1 ? args : args[0];
|
|
@@ -66,7 +91,8 @@ function createHyperScript(r) {
|
|
|
66
91
|
return list;
|
|
67
92
|
};
|
|
68
93
|
r.dynamicProperty(props, k);
|
|
69
|
-
} else if (typeof d[k].value === "function" && !d[k].value.length)
|
|
94
|
+
} else if (typeof d[k].value === "function" && !d[k].value.length)
|
|
95
|
+
r.dynamicProperty(props, k);
|
|
70
96
|
}
|
|
71
97
|
e = r.createComponent(l, props);
|
|
72
98
|
args = [];
|
|
@@ -83,7 +109,12 @@ function createHyperScript(r) {
|
|
|
83
109
|
const v = m[i],
|
|
84
110
|
s = v.substring(1, v.length);
|
|
85
111
|
if (!v) continue;
|
|
86
|
-
if (!e)
|
|
112
|
+
if (!e)
|
|
113
|
+
e = r.SVGElements.has(v)
|
|
114
|
+
? document.createElementNS("http://www.w3.org/2000/svg", v)
|
|
115
|
+
: document.createElement(v);
|
|
116
|
+
else if (v[0] === ".") classes.push(s);
|
|
117
|
+
else if (v[0] === "#") e.setAttribute("id", s);
|
|
87
118
|
}
|
|
88
119
|
}
|
|
89
120
|
function detectMultiExpression(list) {
|
package/jsx-runtime/dist/jsx.js
CHANGED
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.
|
|
4
|
+
"version": "2.0.0-experimental.2",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -46,8 +46,7 @@
|
|
|
46
46
|
"./types/*": "./types/*"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"
|
|
50
|
-
"@solidjs/web": "^2.0.0-experimental.1"
|
|
49
|
+
"@solidjs/web": "^2.0.0-experimental.2"
|
|
51
50
|
},
|
|
52
51
|
"devDependencies": {
|
|
53
52
|
"@solidjs/web": "2.0.0-experimental.1"
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type { JSX } from "./jsx.d.ts";
|
|
2
|
-
import type { JSX } from "./jsx.d.ts";
|
|
3
|
-
declare function Fragment(props: { children: JSX.Element }): JSX.Element;
|
|
4
|
-
declare function jsx(
|
|
5
|
-
type: any,
|
|
6
|
-
props: any
|
|
7
|
-
): () =>
|
|
8
|
-
| (Node & {
|
|
9
|
-
[key: string]: any;
|
|
10
|
-
})
|
|
11
|
-
| (Node & {
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
})[];
|
|
14
|
-
export { jsx, jsx as jsxs, jsx as jsxDEV, Fragment };
|