@ecopages/browser-router 0.2.0-alpha.18 → 0.2.0-alpha.19
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/CHANGELOG.md +1 -0
- package/README.md +1 -1
- package/package.json +2 -2
- package/src/client/services/dom-swapper.js +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -15,6 +15,7 @@ All notable changes to `@ecopages/browser-router` are documented here.
|
|
|
15
15
|
- Fixed navigation races, duplicate script injection, and stale cleanup during repeated page swaps.
|
|
16
16
|
- Fixed mixed-runtime document ownership, script reruns, persisted head scripts, and client-managed `<html>` state during browser-router navigations.
|
|
17
17
|
- Fixed skipped View Transition lifecycle aborts leaking as unhandled browser-router test errors.
|
|
18
|
+
- Fixed body morph swaps retaining stale content when pages contain duplicate `id` attributes by limiting morphdom keying to explicitly persisted nodes.
|
|
18
19
|
|
|
19
20
|
### Refactoring
|
|
20
21
|
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecopages/browser-router",
|
|
3
|
-
"version": "0.2.0-alpha.
|
|
3
|
+
"version": "0.2.0-alpha.19",
|
|
4
4
|
"description": "Client-side router for Ecopages with view transitions support",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ecopages",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"morphdom": "^2.7.8"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@ecopages/core": "0.2.0-alpha.
|
|
38
|
+
"@ecopages/core": "0.2.0-alpha.19"
|
|
39
39
|
},
|
|
40
40
|
"types": "./src/index.d.ts"
|
|
41
41
|
}
|
|
@@ -7,6 +7,12 @@ function isPersisted(element, persistAttribute) {
|
|
|
7
7
|
function isHydratedCustomElement(element) {
|
|
8
8
|
return element.localName.includes("-") && element.shadowRoot !== null;
|
|
9
9
|
}
|
|
10
|
+
function getBodyMorphKey(element, persistAttribute) {
|
|
11
|
+
if (!(element instanceof Element)) {
|
|
12
|
+
return void 0;
|
|
13
|
+
}
|
|
14
|
+
return element.getAttribute(persistAttribute) || element.getAttribute(DEFAULT_PERSIST_ATTR) || void 0;
|
|
15
|
+
}
|
|
10
16
|
class DomSwapper {
|
|
11
17
|
persistAttribute;
|
|
12
18
|
pendingHeadScripts = [];
|
|
@@ -261,6 +267,7 @@ class DomSwapper {
|
|
|
261
267
|
const persistAttr = this.persistAttribute;
|
|
262
268
|
const deferredReplacements = [];
|
|
263
269
|
morphdom(document.body, newDocument.body, {
|
|
270
|
+
getNodeKey: (node) => getBodyMorphKey(node, persistAttr),
|
|
264
271
|
onBeforeElUpdated: (fromEl, toEl) => {
|
|
265
272
|
if (isPersisted(fromEl, persistAttr)) {
|
|
266
273
|
return false;
|