what-server 0.4.0 → 0.5.0
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/package.json +3 -3
- package/src/index.js +14 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "what-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "What Framework - SSR, islands architecture, static generation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"author": "",
|
|
33
33
|
"license": "MIT",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"what-core": "^0.
|
|
35
|
+
"what-core": "^0.5.0"
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
39
|
-
"url": "https://github.com/aspect/what-fw"
|
|
39
|
+
"url": "git+https://github.com/aspect/what-fw.git"
|
|
40
40
|
}
|
|
41
41
|
}
|
package/src/index.js
CHANGED
|
@@ -34,7 +34,10 @@ export function renderToString(vnode) {
|
|
|
34
34
|
// Void elements
|
|
35
35
|
if (VOID_ELEMENTS.has(tag)) return open;
|
|
36
36
|
|
|
37
|
-
const
|
|
37
|
+
const rawInner = props?.dangerouslySetInnerHTML?.__html
|
|
38
|
+
?? props?.innerHTML?.__html
|
|
39
|
+
?? props?.innerHTML;
|
|
40
|
+
const inner = rawInner != null ? String(rawInner) : children.map(renderToString).join('');
|
|
38
41
|
return `${open}${inner}</${tag}>`;
|
|
39
42
|
}
|
|
40
43
|
|
|
@@ -69,8 +72,15 @@ export async function* renderToStream(vnode) {
|
|
|
69
72
|
yield `<${tag}${attrs}>`;
|
|
70
73
|
|
|
71
74
|
if (!VOID_ELEMENTS.has(tag)) {
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
const rawInner = props?.dangerouslySetInnerHTML?.__html
|
|
76
|
+
?? props?.innerHTML?.__html
|
|
77
|
+
?? props?.innerHTML;
|
|
78
|
+
if (rawInner != null) {
|
|
79
|
+
yield String(rawInner);
|
|
80
|
+
} else {
|
|
81
|
+
for (const child of children) {
|
|
82
|
+
yield* renderToStream(child);
|
|
83
|
+
}
|
|
74
84
|
}
|
|
75
85
|
yield `</${tag}>`;
|
|
76
86
|
}
|
|
@@ -159,7 +169,7 @@ export function server(Component) {
|
|
|
159
169
|
function renderAttrs(props) {
|
|
160
170
|
let out = '';
|
|
161
171
|
for (const [key, val] of Object.entries(props)) {
|
|
162
|
-
if (key === 'key' || key === 'ref' || key === 'children' || key === 'dangerouslySetInnerHTML') continue;
|
|
172
|
+
if (key === 'key' || key === 'ref' || key === 'children' || key === 'dangerouslySetInnerHTML' || key === 'innerHTML') continue;
|
|
163
173
|
if (key.startsWith('on') && key.length > 2) continue; // Skip event handlers in SSR
|
|
164
174
|
if (val === false || val == null) continue;
|
|
165
175
|
|
|
@@ -177,11 +187,6 @@ function renderAttrs(props) {
|
|
|
177
187
|
}
|
|
178
188
|
}
|
|
179
189
|
|
|
180
|
-
// Handle dangerouslySetInnerHTML separately
|
|
181
|
-
if (props.dangerouslySetInnerHTML) {
|
|
182
|
-
// This is handled in the content rendering, not attrs
|
|
183
|
-
}
|
|
184
|
-
|
|
185
190
|
return out;
|
|
186
191
|
}
|
|
187
192
|
|