Skip to content
This repository has been archived by the owner on Sep 23, 2023. It is now read-only.

Commit

Permalink
POTENTIAL SOLUTION FOUND! 🎉
Browse files Browse the repository at this point in the history
  • Loading branch information
cheng-alvin committed Sep 7, 2023
1 parent 9500308 commit 1ae2942
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions packages/core/src/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@ export function componentFactory(innerHTML) {
innerHTML = innerHTML.replaceAll("&lt;", "<").replaceAll("&gt;", ">");

return class Component extends HTMLElement {
connectedCallback() {
// Solution? - Alvin
const scriptElements = this.shadowRoot.querySelectorAll("script");

scriptElements.forEach((script) => {
const newScript = document.createElement("script");
newScript.textContent = script.textContent;
this.shadowRoot.appendChild(newScript);
script.remove();
});
}

constructor() {
super();
this.attachShadow({ mode: "open" });
Expand Down

0 comments on commit 1ae2942

Please sign in to comment.