Re: [webcomponents] HTML Imports

On Sun, Oct 6, 2013 at 9:38 AM, Dimitri Glazkov <dglazkov@chromium.org> wrote:
>> So you have <link href=blah.html> in meh.html and blah.html is:
>> <div id=test></div>
>> <script> /* how do I get to #test? */ </script>
> document.currentScript.ownerDocument.querySelector("#test") :)

This only works for code running directly in the script. The current
setup means that any time an author has something like:

<template id="foo">...</template>
<script>
function cloneFoo() { /* get foo and return it. */ }
</script>

they'll have to use a closure to capture the document that the
template lives in, which is rather surprising to me. Also, storing the
document in a global variable is a footgun, because that global
variable would potentially collide with another import trying to do
the same thing. ES6 modules would help here, but there a way's off.

> I think the greatest impact here will be on developers. They have to start
> thinking in terms of multiple documents. We should ask Polymer people: they
> wrote a ton of code with Imports now and I bet they have opinions.

Out of curiosity, what have the Polymer guys been using imports for?
More than just declaring custom elements? I'm worried that we're
coming up with a very generic feature with odd semantics that only
make sense for one narrow use-case.
-- 
Blake Kaplan

Received on Friday, 18 October 2013 22:37:40 UTC