elegance-js 1.17.4 → 1.17.5

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.
@@ -438,7 +438,36 @@ var navigateLocally = async (target, pushState = true) => {
438
438
  }
439
439
  }
440
440
  oldPageLatest.replaceWith(newPageLatest);
441
- doc.head.replaceWith(newPage.head);
441
+ {
442
+ doc.head.querySelector("title")?.replaceWith(
443
+ newPage.head.querySelector("title") ?? ""
444
+ );
445
+ const update = (targetList, matchAgainst, action) => {
446
+ for (const target2 of targetList) {
447
+ const matching = matchAgainst.find((n) => n.isEqualNode(target2));
448
+ if (matching) {
449
+ continue;
450
+ }
451
+ action(target2);
452
+ }
453
+ };
454
+ const oldTags = Array.from([
455
+ ...Array.from(document.head.querySelectorAll("link")),
456
+ ...Array.from(document.head.querySelectorAll("meta")),
457
+ ...Array.from(document.head.querySelectorAll("script")),
458
+ ...Array.from(document.head.querySelectorAll("base")),
459
+ ...Array.from(document.head.querySelectorAll("style"))
460
+ ]);
461
+ const newTags = Array.from([
462
+ ...Array.from(newPage.head.querySelectorAll("link")),
463
+ ...Array.from(newPage.head.querySelectorAll("meta")),
464
+ ...Array.from(newPage.head.querySelectorAll("script")),
465
+ ...Array.from(newPage.head.querySelectorAll("base")),
466
+ ...Array.from(newPage.head.querySelectorAll("style"))
467
+ ]);
468
+ update(newTags, oldTags, (node) => document.head.appendChild(node));
469
+ update(oldTags, newTags, (node) => node.remove());
470
+ }
442
471
  if (pushState) history.pushState(null, "", targetURL.href);
443
472
  loadPage(currentPage);
444
473
  currentPage = pathname;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "1.17.4",
3
+ "version": "1.17.5",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "bin": {