@absolutejs/absolute 0.17.13 → 0.17.14

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.
@@ -61,7 +61,7 @@
61
61
  "src/dev/client/handlers/angularRuntime.ts": "2953p2hoftx5u",
62
62
  "src/dev/client/handlers/vue.ts": "1q7sk9jnhk8gc",
63
63
  "src/dev/client/handlers/htmx.ts": "3njirexjzjfbd",
64
- "src/dev/client/handlers/svelte.ts": "gg4r1hqdgg3a",
64
+ "src/dev/client/handlers/svelte.ts": "3egd9ql8o82ko",
65
65
  "src/utils/escapeScriptContent.ts": "1gg8nciaxrh5v",
66
66
  "src/utils/logger.ts": "2bxszbbyp39u9",
67
67
  "src/utils/ssrErrorPage.ts": "2oxyhfys2xq0i",
@@ -133,7 +133,7 @@
133
133
  "example/angular/compiled/mm51rigw/components/counter.component.js": "26dxmwf0w68tf",
134
134
  "eslint.config.mjs": "3jvlmsyhtijzc",
135
135
  "tsconfig.json": "7ocytjowy50m",
136
- "package.json": "fslx4gvzgntw",
136
+ "package.json": "1m3pid2yuj5bw",
137
137
  "tsconfig.build.json": "976e92rva922",
138
138
  "example/svelte/pages/SvelteExample.svelte": "1um210xkshf8o",
139
139
  "example/svelte/components/Counter.svelte": "1p92uo1pko0wo",
@@ -107,26 +107,55 @@ export const handleSvelteUpdate = (message: {
107
107
  );
108
108
  }
109
109
 
110
- /* Preserve existing stylesheets so they survive the unmount/mount cycle.
111
- Svelte removes <svelte:head> content (including <link> tags) on unmount,
112
- causing FOUC when a child component changes (no cssUrl to pre-load). */
113
- const headLinks = document.querySelectorAll<HTMLLinkElement>(
114
- 'head link[rel="stylesheet"]'
115
- );
116
- headLinks.forEach(function (link) {
117
- const clone = link.cloneNode(true) as HTMLLinkElement;
118
- clone.dataset.hmrPreserved = 'true';
119
- document.head.appendChild(clone);
120
- });
110
+ /* Preserve styles as inline <style> elements so they survive the
111
+ unmount/mount cycle. Svelte removes <svelte:head> content (including
112
+ <link> tags) on unmount. Inline styles apply synchronously unlike
113
+ cloned <link> tags which need to re-fetch even from cache. */
114
+ const preservedStyles: HTMLStyleElement[] = [];
115
+ document
116
+ .querySelectorAll<HTMLLinkElement>('head link[rel="stylesheet"]')
117
+ .forEach(function (link) {
118
+ try {
119
+ const sheet = link.sheet;
120
+ if (sheet && sheet.cssRules.length > 0) {
121
+ const style = document.createElement('style');
122
+ style.dataset.hmrPreserved = 'true';
123
+ let rules = '';
124
+ for (let idx = 0; idx < sheet.cssRules.length; idx++) {
125
+ rules += sheet.cssRules[idx]!.cssText + '\n';
126
+ }
127
+ style.textContent = rules;
128
+ document.head.appendChild(style);
129
+ preservedStyles.push(style);
130
+ }
131
+ } catch (_err) {
132
+ /* Cross-origin sheets (e.g. Google Fonts) — clone as fallback */
133
+ const clone = link.cloneNode(true) as HTMLLinkElement;
134
+ clone.dataset.hmrPreserved = 'true';
135
+ document.head.appendChild(clone);
136
+ }
137
+ });
138
+
139
+ /* Also preserve Svelte injected <style> tags (css: 'injected' mode) */
140
+ document
141
+ .querySelectorAll<HTMLStyleElement>(
142
+ 'head style:not([data-hmr-preserved])'
143
+ )
144
+ .forEach(function (style) {
145
+ const clone = document.createElement('style');
146
+ clone.dataset.hmrPreserved = 'true';
147
+ clone.textContent = style.textContent;
148
+ document.head.appendChild(clone);
149
+ });
121
150
 
122
151
  const modulePath = indexPath + '?t=' + Date.now();
123
152
  import(/* @vite-ignore */ modulePath)
124
153
  .then(function () {
125
- /* Remove preserved copies — new svelte:head has re-added fresh ones */
154
+ /* Remove preserved copies — new svelte:head and mount() added fresh ones */
126
155
  document
127
- .querySelectorAll('link[data-hmr-preserved="true"]')
128
- .forEach(function (link) {
129
- link.remove();
156
+ .querySelectorAll('[data-hmr-preserved="true"]')
157
+ .forEach(function (element) {
158
+ element.remove();
130
159
  });
131
160
  restoreDOMState(document.body, domState);
132
161
  restoreScrollState(scrollState);
package/package.json CHANGED
@@ -145,5 +145,5 @@
145
145
  "typecheck": "bun run vue-tsc --noEmit"
146
146
  },
147
147
  "types": "./dist/src/index.d.ts",
148
- "version": "0.17.13"
148
+ "version": "0.17.14"
149
149
  }