danieldietrich / candid

Candid is a surprisingly fresh and frameworkless JavaScript library for building web applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support <script src="...."> in web component templates?

danieldietrich opened this issue · comments

Currently, the component processor only reads <script> contents. It would be nice to by able to load scripts dynamically. Maybe we can just leave the <script> tags in the DOM (resp. as part of the template) and the browser does the job when cloning the template to the custom element root?

I see the following problems with that approach:

  • a <script src="..."> cannot bind this. we currently rely on that because a script sees the component's __ctx object as this. I don't see how this should work...
  • when a component is loaded from a different location, a relative url in src does not point to the right resource anymore. we could fix that by rewriting relative urls with the right base-url

See also #20