elegance-js 2.1.29 → 2.1.31

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.
@@ -77,7 +77,7 @@ function createHTMLElementFromElement(element) {
77
77
  DEV_BUILD && (() => {
78
78
  let isErrored = false;
79
79
  (function connect() {
80
- const es = new EventSource("http://localhost:4000/elegance-hot-reload");
80
+ const es = new EventSource(`${window.location.origin}/elegance-hot-reload`);
81
81
  es.onopen = () => {
82
82
  if (isErrored) {
83
83
  window.location.reload();
@@ -429,16 +429,18 @@ const fetchPage = async (targetURL) => {
429
429
  // get page script
430
430
  {
431
431
  const pageDataScript = newDOM.querySelector(`script[data-hook="true"][data-pathname="${pathname}"]`);
432
- const text = pageDataScript.textContent;
433
- pageDataScript.remove();
434
- const blob = new Blob([text], { type: 'text/javascript' });
435
- const url = URL.createObjectURL(blob);
436
- const script = document.createElement("script");
437
- script.src = url;
438
- script.type = "module";
439
- script.setAttribute("data-page", "true");
440
- script.setAttribute("data-pathname", `${pathname}`);
441
- newDOM.head.appendChild(script);
432
+ if (pageDataScript) {
433
+ const text = pageDataScript.textContent;
434
+ pageDataScript.remove();
435
+ const blob = new Blob([text], { type: 'text/javascript' });
436
+ const url = URL.createObjectURL(blob);
437
+ const script = document.createElement("script");
438
+ script.src = url;
439
+ script.type = "module";
440
+ script.setAttribute("data-page", "true");
441
+ script.setAttribute("data-pathname", `${pathname}`);
442
+ newDOM.head.appendChild(script);
443
+ }
442
444
  }
443
445
  pageStringCache.set(pathname, xmlSerializer.serializeToString(newDOM));
444
446
  return newDOM;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "elegance-js",
3
- "version": "2.1.29",
3
+ "version": "2.1.31",
4
4
  "description": "Web-Framework",
5
5
  "type": "module",
6
6
  "main": "dist/index.mjs",