@cfdez11/vex 0.8.0 → 0.8.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/package.json
CHANGED
package/server/build-static.js
CHANGED
|
@@ -38,6 +38,7 @@ let shell = rootTemplate
|
|
|
38
38
|
.replace(/\{\{props\.children\}\}/g, "");
|
|
39
39
|
|
|
40
40
|
const frameworkScripts = [
|
|
41
|
+
`<style>vex-root { display: contents; }</style>`,
|
|
41
42
|
`<script type="module" src="/_vexjs/services/index.js"></script>`,
|
|
42
43
|
`<script src="/_vexjs/services/hydrate-client-components.js"></script>`,
|
|
43
44
|
`<script src="/_vexjs/services/hydrate.js" id="hydrate-script"></script>`,
|
|
@@ -564,6 +564,7 @@ async function renderLayouts(pagePath, pageContent, pageHead = {}) {
|
|
|
564
564
|
// so users don't need to reference framework scripts in their root.html
|
|
565
565
|
const devMode = process.env.NODE_ENV !== "production";
|
|
566
566
|
const frameworkScripts = [
|
|
567
|
+
`<style>vex-root { display: contents; }</style>`,
|
|
567
568
|
`<script type="module" src="/_vexjs/services/index.js"></script>`,
|
|
568
569
|
`<script src="/_vexjs/services/hydrate-client-components.js"></script>`,
|
|
569
570
|
`<script src="/_vexjs/services/hydrate.js" id="hydrate-script"></script>`,
|
|
@@ -832,6 +833,11 @@ export async function generateClientComponentModule({
|
|
|
832
833
|
// ── 5. Assemble the esbuild entry source ────────────────────────────────────
|
|
833
834
|
// This is a valid ESM module that esbuild will bundle. Imports at the top,
|
|
834
835
|
// hydrateClientComponent exported as a named function.
|
|
836
|
+
// Add persistent wrapper element anchors the component in the DOM so that
|
|
837
|
+
// re-renders always have a stable target to replace children into.
|
|
838
|
+
// Using a plain Element (never a DocumentFragment) avoids the fragment-drain
|
|
839
|
+
// problem: after marker.replaceWith(fragment) the fragment empties and
|
|
840
|
+
// disconnects, making subsequent root.replaceWith() calls silently no-op.
|
|
835
841
|
const entrySource = `
|
|
836
842
|
${[...importLines].join("\n")}
|
|
837
843
|
|
|
@@ -840,20 +846,16 @@ export const metadata = ${JSON.stringify(metadata)};
|
|
|
840
846
|
export function hydrateClientComponent(marker, incomingProps = {}) {
|
|
841
847
|
${cleanClientCode}
|
|
842
848
|
|
|
843
|
-
|
|
849
|
+
const wrapper = document.createElement("vex-root");
|
|
850
|
+
marker.replaceWith(wrapper);
|
|
851
|
+
|
|
844
852
|
function render() {
|
|
845
853
|
const node = html\`${processedHtml}\`;
|
|
846
|
-
|
|
847
|
-
root = node;
|
|
848
|
-
marker.replaceWith(node);
|
|
849
|
-
} else {
|
|
850
|
-
root.replaceWith(node);
|
|
851
|
-
root = node;
|
|
852
|
-
}
|
|
854
|
+
wrapper.replaceChildren(node);
|
|
853
855
|
}
|
|
854
856
|
|
|
855
857
|
effect(() => render());
|
|
856
|
-
return
|
|
858
|
+
return wrapper;
|
|
857
859
|
}
|
|
858
860
|
`.trim();
|
|
859
861
|
|