Skip to content

Commit

Permalink
Re-attach custom elements on custom element node update
Browse files Browse the repository at this point in the history
  • Loading branch information
zachleat committed Sep 4, 2024
1 parent ea09909 commit c7ead8e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/reload-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ class EleventyReload {
window.location.reload();
}
},
onElUpdated: function(node) {
// Re-attach custom elements
if(customElements.get(node.tagName.toLowerCase())) {
let placeholder = document.createElement("div");
node.replaceWith(placeholder);
requestAnimationFrame(() => {
placeholder.replaceWith(node);
placeholder = undefined;
});
}
}
});

Util.matchRootAttributes(template.content);
Expand Down

0 comments on commit c7ead8e

Please sign in to comment.