vaderjs 1.8.9 → 1.9.1
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/bundler/index.js +20 -7
- package/index.ts +9 -5
- package/package.json +1 -1
package/bundler/index.js
CHANGED
|
@@ -33,6 +33,22 @@ globalThis.document = {
|
|
|
33
33
|
getElementById: (id) => { },
|
|
34
34
|
querySelector: (query) => { },
|
|
35
35
|
};
|
|
36
|
+
globalThis.window = {
|
|
37
|
+
addEventListener: (event, cb) => { },
|
|
38
|
+
removeEventListener: (event, cb) => { },
|
|
39
|
+
localStorage: {
|
|
40
|
+
setItem: (key, value) => { },
|
|
41
|
+
getItem: (key) => { },
|
|
42
|
+
},
|
|
43
|
+
sessionStorage: {
|
|
44
|
+
setItem: (key, value) => { },
|
|
45
|
+
getItem: (key) => { },
|
|
46
|
+
},
|
|
47
|
+
location: {
|
|
48
|
+
href: "",
|
|
49
|
+
pathname: "",
|
|
50
|
+
},
|
|
51
|
+
}
|
|
36
52
|
try {
|
|
37
53
|
await Bun.build({
|
|
38
54
|
entrypoints: [process.env.ENTRYPOINT],
|
|
@@ -177,21 +193,18 @@ const generatePage = async (
|
|
|
177
193
|
|
|
178
194
|
|
|
179
195
|
|
|
180
|
-
|
|
181
|
-
h = h.replace("<head>", `<head>${process.env.bindes}`)
|
|
182
|
-
} else {
|
|
183
|
-
h += process.env.bindes
|
|
184
|
-
}
|
|
185
|
-
|
|
196
|
+
|
|
186
197
|
await Bun.write(
|
|
187
198
|
process.cwd() + "/dist/" + route + "/index.html",
|
|
188
199
|
`<!DOCTYPE html>
|
|
200
|
+
|
|
201
|
+
${process.env.bindes}
|
|
189
202
|
${h}
|
|
190
203
|
<script type="module">
|
|
191
204
|
import c from '${process.env.filePath}'
|
|
192
205
|
import {render, e} from '/src/vader/index.js'
|
|
193
206
|
window.e = e
|
|
194
|
-
render(c, document.body
|
|
207
|
+
render(c, document.body)
|
|
195
208
|
</script>
|
|
196
209
|
`
|
|
197
210
|
);
|
package/index.ts
CHANGED
|
@@ -185,8 +185,8 @@ interface SwitchProps {
|
|
|
185
185
|
// make children optional
|
|
186
186
|
export function Switch({ children = [] }: SwitchProps) {
|
|
187
187
|
for (let child of children) {
|
|
188
|
-
if (child
|
|
189
|
-
return child
|
|
188
|
+
if (child.props.when) {
|
|
189
|
+
return child
|
|
190
190
|
}
|
|
191
191
|
}
|
|
192
192
|
return { type: "div", props: {}, children: [] };
|
|
@@ -620,9 +620,13 @@ export class Component {
|
|
|
620
620
|
const handler = attributes[key];
|
|
621
621
|
this.eventRegistry.set(el, [...(this.eventRegistry.get(el) || []), { event: eventType, handler }]);
|
|
622
622
|
this.addEventListener(el, eventType, handler);
|
|
623
|
-
} else if (attributes[key] !== null && attributes[key] !== undefined
|
|
624
|
-
|
|
625
|
-
|
|
623
|
+
} else if (attributes[key] !== null && attributes[key] !== undefined &&
|
|
624
|
+
!key.includes(" ") || !key.includes("-") || !key.includes("_")) {
|
|
625
|
+
try {
|
|
626
|
+
el.setAttribute(key, attributes[key]);
|
|
627
|
+
} catch (error) {
|
|
628
|
+
|
|
629
|
+
}
|
|
626
630
|
}
|
|
627
631
|
}
|
|
628
632
|
|