Importing modules inside HTML imports

John Barton johnjbarton at google.com
Fri Aug 15 17:46:59 PDT 2014


On Fri, Aug 15, 2014 at 3:06 PM, Ian Hickson <ian at hixie.ch> wrote:

>
> Suppose you have an HTML import foo.html that declares two modules:
>
>    <script type=module id=a> ... </script>
>    <script type=module id=b> ... </script>
>

As we noted in another thread, Web devs no longer control servers. And
servers no longer allow inline script (for the most part going forward). So
I don't see this feature as worth investing effort in. (I don't like it
either, but it is what it is).


>
> How should they refer to each other? For example, if module id=b wants to
> import module id=a? I suppose the logical way is like this:
>
>    import "#a";
>

import './a';


>
> Now, in the main page, you reference the HTML import:
>
>    <link rel=import href="foo.html">
>
> Now how would you refer to the modules? We can't have #b refer to it,
> since the scope of IDs is per-document, and the import has a separate
> document.


Separate document implies separate JS global: each needs its own Loader. So
the rest of the questions aren't needed.



> The logical way to do it would be:
>
>    import "foo.html#a";
>
> ...but that means that "#a" and "foo.html#a" should resolve to the same
> canonical string in the "normalize" hook. Presumably then, that's the full
> absolute URL? And we look up the document in the import list? But what if
> the import hasn't been instantiated yet? Should "normalize" just wait
> until it has been? (Otherwise, the module registry won't have the module
> and so "locate" will be called and "locate" won't have any idea what to do
> with that URL.)
>
> None of this is very compelling. Is there some expected way to do this
> that I haven't thought of?
>
> (Similar questions apply to referencing other things in imports, e.g.
> style sheets, images, etc.)
>
> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140815/39b1bfdb/attachment-0001.html>


More information about the es-discuss mailing list