0

Why in the world wide web is it so hard to use JavaScript to dynamically create a custom web component element after the page has loaded!? I swear I must be missing something obvious. I know it isn't working because document.currentScript.ownerDocument is null and I use that to get the template and it works great if the elements are on the page already but it fails as soon as I try to use JS to create a new element of that component and I can't figure it out!

I could easily change the pages to be pre-rendered with data and it'd work fine but I plan on building in a service worker to cache the page skeleton and store the elements in IDB.

(This has been just a fun side project for me this week, until now it's turned into a frustrating project I spent most of my night on)

Comments
  • 0
    Of course all I had to do was store the document with the template outside of the component declaration. 3 hours spent debugging just to find out I had to move one line of code. Nothing even needed changes. Good job Nathan...
Add Comment