Importing modules inside HTML imports

Ian Hickson ian at hixie.ch
Fri Aug 15 15:06:45 PDT 2014


Suppose you have an HTML import foo.html that declares two modules:

   <script type=module id=a> ... </script>
   <script type=module id=b> ... </script>

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";

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. 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.   `._.-(,_..'--(,_..'`-.;.'


More information about the es-discuss mailing list