Skip to content

Commit

Permalink
Fixes #90
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Sep 4, 2024
1 parent c05c3bf commit d333c8e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions client/reload-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ class Util {

let oldWithoutHref = from.cloneNode();
let newWithoutHref = to.cloneNode();

oldWithoutHref.removeAttribute("href");
newWithoutHref.removeAttribute("href");

// if all other attributes besides href match
if(!oldWithoutHref.isEqualNode(newWithoutHref)) {
return false;
Expand Down Expand Up @@ -161,7 +161,7 @@ class EleventyReload {
// no reconnection when the connect is already open
this.removeReconnectListeners();
});

socket.addEventListener("close", () => {
this.connectionMessageShown = false;
this.addReconnectListeners();
Expand Down Expand Up @@ -219,6 +219,17 @@ class EleventyReload {

return true;
},
addChild: function(parent, child) {
// Declarative Shadow DOM https://github.com/11ty/eleventy-dev-server/issues/90
if(child.nodeName === "TEMPLATE" && child.hasAttribute("shadowrootmode") && parent.shadowRoot) {
for(let oldChild of parent.shadowRoot?.childNodes || []) {
oldChild.remove();
}
for(let newChild of child.content.childNodes) {
parent.shadowRoot.appendChild(newChild);
}
}
},
onNodeAdded: function (node) {
if (node.nodeName === 'SCRIPT') {
Util.runScript(node);
Expand Down

0 comments on commit d333c8e

Please sign in to comment.