You can use document._currentScript to support polyfill'd environments.

http://webcomponents.org/polyfills/html-imports/#other-notes

On Mon, Mar 16, 2015 at 3:12 AM <[email protected]> wrote:

> Hi List,
>
> I could not find a mailing list for the webcomponents.js polyfill. Please
> redirect me to that list if it exists.
>
> I have been experimenting with web components lately. Looks like a great
> step forward. Thank you to all whom contributed.
>
> Here is my issue:
>
> test.html looks like this
>
> <html>
>   <head>
>     <script src="webcomponents-0.5.5.js"></script>
>     <link rel="import" href="xprogressbar.html"/>
>   </head>
>   <body>
>     <h1>Testing x-progressbar</h1>
>     <div class="xprogressbar" data-done="50" data-todo="40"
> data-budget="100"
>          data-width="100" data-height="20" data-fontsize="2em"></div>
>   </body>
> </html>
>
> and xprogressbar.html like this:
>
> <template id="x-progressbar-template">
>   [...]
> </template>
>
> <script src="xprogressbar.js"></script>
> <script>
> (function() {
>   var importDoc = document.currentScript.ownerDocument;
>   var proto = Object.create(HTMLElement.prototype);
>   proto.createdCallback = function() {
>     init_xprogressbar(this, importDoc);
>   };
>   document.registerElement('x-progressbar', {prototype: proto});
> })();
> </script>
>
> The above works fine in Chromium 37 and in Iceweasel (Firefox) 36 when
> dom.webcomponents.enabled = true.
>
> But with Firefox 36, document.currentScript.ownerDocument points to
> test.html instead of xprogressbar.html.
>
> Any help or pointer will be welcome.
>
> Follow Polymer on Google+: plus.google.com/107187849809354688692
> ---
> You received this message because you are subscribed to the Google Groups
> "Polymer" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/polymer-dev/4ec7bf70-3eb5-4a0f-860d-3f7442037510%40googlegroups.com
> <https://groups.google.com/d/msgid/polymer-dev/4ec7bf70-3eb5-4a0f-860d-3f7442037510%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

Follow Polymer on Google+: plus.google.com/107187849809354688692
--- 
You received this message because you are subscribed to the Google Groups 
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/polymer-dev/CACGqRCC-_cfgpzr_dQAHh%2BYz_P4bMmYxti1j-XgE19J9q10Vsw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to