vite-plugin-vanjs 0.1.24 → 0.1.25

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/client/index.mjs CHANGED
@@ -108,18 +108,24 @@ export function elementsMatch(el1, el2, deep) {
108
108
  return false;
109
109
  }
110
110
 
111
- const childNodes1 = Array.from(el1.childNodes);
112
- const childNodes2 = Array.from(el2.childNodes);
111
+ // Filter empty text nodes — SSR omits them, client creates Text("")
112
+ // from function children returning ""
113
+ const cn1 = Array.from(el1.childNodes).filter((n) =>
114
+ n.nodeType !== 3 || /* istanbul ignore next */ n.textContent !== ""
115
+ );
116
+ const cn2 = Array.from(el2.childNodes).filter((n) =>
117
+ n.nodeType !== 3 || /* istanbul ignore next */ n.textContent !== ""
118
+ );
113
119
 
114
120
  // istanbul ignore else
115
- if (childNodes1.length !== childNodes2.length) {
121
+ if (cn1.length !== cn2.length) {
116
122
  return false;
117
123
  }
118
124
 
119
125
  // Only recurse if necessary (has childNodes with data-hk)
120
- const hasHydratedChildren = childNodes1.some((child) =>
121
- child instanceof HTMLElement && (child.hasAttribute("data-hk") ||
122
- child.querySelector("[data-hk]"))
126
+ const hasHydratedChildren = cn1.some((child) =>
127
+ child instanceof HTMLElement &&
128
+ (child.hasAttribute("data-hk") || child.querySelector("[data-hk]"))
123
129
  );
124
130
 
125
131
  // istanbul ignore next
@@ -130,7 +136,7 @@ export function elementsMatch(el1, el2, deep) {
130
136
  // Only recurse if opted in
131
137
  // istanbul ignore next
132
138
  return deep
133
- ? childNodes1.every((child, idx) => elementsMatch(child, childNodes2[idx]))
139
+ ? cn1.every((child, idx) => elementsMatch(child, cn2[idx]))
134
140
  : true;
135
141
  }
136
142
 
@@ -279,4 +285,5 @@ export const hydrate = (target, content) => {
279
285
  target.replaceChildren(...parsed);
280
286
  }
281
287
  }
288
+ return target;
282
289
  };
package/meta/global.d.ts CHANGED
@@ -40,7 +40,10 @@ declare module "@vanjs/meta" {
40
40
  ) => null;
41
41
 
42
42
  export const Meta: (
43
- props: PropsWithKnownKeys<HTMLMetaElement> & { charset?: string & "utf-8" },
43
+ props: PropsWithKnownKeys<HTMLMetaElement> & {
44
+ charset?: string & "utf-8";
45
+ property?: string;
46
+ },
44
47
  ) => null;
45
48
 
46
49
  export const Style: (
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-vanjs",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
4
4
  "author": "thednp",
5
5
  "license": "MIT",
6
6
  "description": "An async first mini meta-framework for VanJS powered by Vite",
@@ -88,14 +88,14 @@
88
88
  "vanjs-ext": "^0.6.3"
89
89
  },
90
90
  "devDependencies": {
91
- "@types/node": "^25.6.2",
92
- "@vitest/browser": "^4.1.5",
93
- "@vitest/coverage-istanbul": "^4.1.5",
94
- "@vitest/ui": "^4.1.5",
95
- "happy-dom": "^20.9.0",
91
+ "@types/node": "^25.9.3",
92
+ "@vitest/browser": "^4.1.8",
93
+ "@vitest/coverage-istanbul": "^4.1.8",
94
+ "@vitest/ui": "^4.1.8",
95
+ "happy-dom": "^20.10.3",
96
96
  "typescript": "6.0.3",
97
- "vite": "^8.0.12",
98
- "vitest": "^4.1.5"
97
+ "vite": "^8.0.16",
98
+ "vitest": "^4.1.8"
99
99
  },
100
100
  "engines": {
101
101
  "node": ">=20",
@@ -151,19 +151,22 @@ export const executeModule = async (route, wrapper, ssr) => {
151
151
  if (routerState.loading === true) return;
152
152
  // 0. Set Loading State
153
153
  routerState.loading = true;
154
- // 1. Resolve the module first (to get route lifecycle hooks)
155
- const module = await route.component();
156
- // 2. Execute lifecycle (a complete route includes all props)
157
- await executeLifecycle(Object.assign(route, module.route));
158
- // 3. Resolve children
159
- const children = resolveChildren(module);
160
- // 4. Update <head> in the client
161
- if (!isServer) updateHead();
162
- // 5. Set Loading State
163
- routerState.loading = false;
164
- // 6. Update / replace children in wrapper
165
- if (ssr) return van.add(wrapper, ...children);
166
- else wrapper.replaceChildren(...children);
154
+ try {
155
+ // 1. Resolve the module first (to get route lifecycle hooks)
156
+ const module = await route.component();
157
+ // 2. Execute lifecycle (a complete route includes all props)
158
+ await executeLifecycle(Object.assign(route, module.route));
159
+ // 3. Resolve children
160
+ const children = resolveChildren(module);
161
+ // 4. Update <head> in the client
162
+ if (!isServer) updateHead();
163
+ // 6. Update / replace children in wrapper
164
+ if (ssr) return van.add(wrapper, ...children);
165
+ else wrapper.replaceChildren(...children);
166
+ } finally {
167
+ // 5. Set Loading State
168
+ routerState.loading = false;
169
+ }
167
170
  };
168
171
 
169
172
  /**