@solidrt/core 0.0.25 → 0.0.26
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/AGENTS.md +1 -1
- package/package.json +5 -5
- package/src/renderer.ts +39 -20
package/AGENTS.md
CHANGED
|
@@ -84,7 +84,7 @@ tsconfig.json - the two load-bearing lines are jsx + jsxImportSource:
|
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
Peer deps @solidjs/signals and @solidjs/universal must match (currently
|
|
87
|
-
2.0.0-beta.
|
|
87
|
+
2.0.0-beta.17); bun resolves them from peerDependencies.
|
|
88
88
|
|
|
89
89
|
## Element model (the parts that are easy to get wrong)
|
|
90
90
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solidrt/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.26",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Antoine van Wel",
|
|
6
6
|
"type": "module",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"colord": "^2.9.3"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@solidrt/flux-types": "0.0.
|
|
30
|
+
"@solidrt/flux-types": "0.0.26"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
|
-
"@solidjs/signals": "2.0.0-beta.
|
|
34
|
-
"@solidjs/universal": "2.0.0-beta.
|
|
35
|
-
"solid-js": "2.0.0-beta.
|
|
33
|
+
"@solidjs/signals": "2.0.0-beta.17",
|
|
34
|
+
"@solidjs/universal": "2.0.0-beta.17",
|
|
35
|
+
"solid-js": "2.0.0-beta.17"
|
|
36
36
|
}
|
|
37
37
|
}
|
package/src/renderer.ts
CHANGED
|
@@ -87,6 +87,34 @@ function removeNode(parent: ProxyNode, node: ProxyNode): void {
|
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
// Applies a single prop to a node: routes events to the handler registry,
|
|
91
|
+
// parses color strings/gradients, and forwards everything else to the tree.
|
|
92
|
+
// Shared by the renderer's setProperty hook and by createElement, which since
|
|
93
|
+
// the dom-expressions "universal" template passes static props inline as a
|
|
94
|
+
// second argument rather than as separate setProp calls.
|
|
95
|
+
function applyProp<T>(node: ProxyNode, name: string, value: T): void {
|
|
96
|
+
if (!node) return
|
|
97
|
+
|
|
98
|
+
// console.debug("[srt] applyProp", node.id, name, value)
|
|
99
|
+
|
|
100
|
+
if (/^on[A-Z]/.test(name) && (value == null || typeof value === "function")) {
|
|
101
|
+
setEventHandler(node.id, name, value as Function | null | undefined)
|
|
102
|
+
return
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
if (name === "color" && isGradient(value)) {
|
|
106
|
+
tree.setProperty(node.id, name, value)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
if (name === "color" && typeof value === "string") {
|
|
111
|
+
tree.setProperty(node.id, name, parseColor(value))
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
tree.setProperty(node.id, name, value)
|
|
116
|
+
}
|
|
117
|
+
|
|
90
118
|
export let {
|
|
91
119
|
effect,
|
|
92
120
|
memo,
|
|
@@ -101,7 +129,7 @@ export let {
|
|
|
101
129
|
applyRef,
|
|
102
130
|
ref,
|
|
103
131
|
} = createRenderer<ProxyNode>({
|
|
104
|
-
createElement: (elementType: string): ProxyNode => {
|
|
132
|
+
createElement: (elementType: string, props?: Record<string, any>): ProxyNode => {
|
|
105
133
|
let proxy = createProxyNode(elementType)
|
|
106
134
|
|
|
107
135
|
// console.debug("[srt] createElement", proxy.id, elementType)
|
|
@@ -109,6 +137,15 @@ export let {
|
|
|
109
137
|
if (elementType === "window") tree.createRoot(proxy.id)
|
|
110
138
|
else tree.createNode(proxy.id, elementType)
|
|
111
139
|
|
|
140
|
+
// The universal JSX template hands static props here as an object; children
|
|
141
|
+
// and ref arrive through their own hooks, so skip them.
|
|
142
|
+
if (props) {
|
|
143
|
+
for (let name in props) {
|
|
144
|
+
if (name === "children" || name === "ref") continue
|
|
145
|
+
applyProp(proxy, name, props[name])
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
112
149
|
return proxy
|
|
113
150
|
},
|
|
114
151
|
|
|
@@ -127,26 +164,8 @@ export let {
|
|
|
127
164
|
|
|
128
165
|
isTextNode: (node: ProxyNode): boolean => node?.elementType === "d-span",
|
|
129
166
|
setProperty: <T>(node: ProxyNode, name: string, value: T): void => {
|
|
130
|
-
if (!node) return
|
|
131
|
-
|
|
132
167
|
// console.debug("[srt] setProperty", node.id, name, value)
|
|
133
|
-
|
|
134
|
-
if (/^on[A-Z]/.test(name) && (value == null || typeof value === "function")) {
|
|
135
|
-
setEventHandler(node.id, name, value as Function | null | undefined)
|
|
136
|
-
return
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
if (name === "color" && isGradient(value)) {
|
|
140
|
-
tree.setProperty(node.id, name, value)
|
|
141
|
-
return
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (name === "color" && typeof value === "string") {
|
|
145
|
-
tree.setProperty(node.id, name, parseColor(value))
|
|
146
|
-
return
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
tree.setProperty(node.id, name, value)
|
|
168
|
+
applyProp(node, name, value)
|
|
150
169
|
},
|
|
151
170
|
|
|
152
171
|
insertNode: (parent: ProxyNode, node: ProxyNode, anchor?: ProxyNode): void => {
|