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 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
- if (h.includes("<head>")) {
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.firstChild)
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 && child.props && child.props.when) {
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
- // General attributes
625
- el.setAttribute(key, attributes[key]);
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
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vaderjs",
3
- "version": "1.8.9",
3
+ "version": "1.9.1",
4
4
  "description": "A simple and powerful JavaScript library for building modern web applications.",
5
5
  "bin": {
6
6
  "vaderjs": "./main.js"