@absolutejs/absolute 0.17.14 → 0.17.15-beta.0
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.
|
@@ -151,14 +151,44 @@ export const handleSvelteUpdate = (message: {
|
|
|
151
151
|
const modulePath = indexPath + '?t=' + Date.now();
|
|
152
152
|
import(/* @vite-ignore */ modulePath)
|
|
153
153
|
.then(function () {
|
|
154
|
-
/*
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
/* Wait for new <link> stylesheets (re-added by svelte:head in mount)
|
|
155
|
+
to fully load before removing preserved styles. Without this,
|
|
156
|
+
removing inline preserved styles leaves a gap until <link> loads. */
|
|
157
|
+
const newLinks = document.querySelectorAll<HTMLLinkElement>(
|
|
158
|
+
'head link[rel="stylesheet"]:not([data-hmr-preserved])'
|
|
159
|
+
);
|
|
160
|
+
const loadPromises: Promise<void>[] = [];
|
|
161
|
+
newLinks.forEach(function (link) {
|
|
162
|
+
if (!link.sheet || link.sheet.cssRules.length === 0) {
|
|
163
|
+
loadPromises.push(
|
|
164
|
+
new Promise<void>(function (resolve) {
|
|
165
|
+
link.onload = function () {
|
|
166
|
+
resolve();
|
|
167
|
+
};
|
|
168
|
+
link.onerror = function () {
|
|
169
|
+
resolve();
|
|
170
|
+
};
|
|
171
|
+
setTimeout(resolve, 500);
|
|
172
|
+
})
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
const cleanup = function () {
|
|
178
|
+
document
|
|
179
|
+
.querySelectorAll('[data-hmr-preserved="true"]')
|
|
180
|
+
.forEach(function (element) {
|
|
181
|
+
element.remove();
|
|
182
|
+
});
|
|
183
|
+
restoreDOMState(document.body, domState);
|
|
184
|
+
restoreScrollState(scrollState);
|
|
185
|
+
};
|
|
186
|
+
|
|
187
|
+
if (loadPromises.length > 0) {
|
|
188
|
+
Promise.all(loadPromises).then(cleanup);
|
|
189
|
+
} else {
|
|
190
|
+
cleanup();
|
|
191
|
+
}
|
|
162
192
|
})
|
|
163
193
|
.catch(function (err: unknown) {
|
|
164
194
|
console.warn('[HMR] Svelte import failed, reloading:', err);
|
package/package.json
CHANGED