Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts in HTML Imports should be scoped to the import (treat imports as script modules) (bugzilla: 27836) #157

Closed
hayatoito opened this issue Jul 6, 2015 · 4 comments

Comments

@hayatoito
Copy link
Contributor

Title: Scripts in HTML Imports should be scoped to the import (treat imports as script modules) (bugzilla: 27836)

Migrated from: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27836


comment: 0
comment_url: https://www.w3.org/Bugs/Public/show_bug.cgi?id=27836#c0
Ian 'Hixie' Hickson wrote on 2015-01-15 00:34:48 +0000.

Right now, two HTML imports will stomp on each other if they happen to declare the same globals. Each import should IMHO be in its own module and should export what it wants to export.

@TakayoshiKochi
Copy link
Member

Once HTML Imports is redefined on top of ES6 modules, all <script> tags will be parsed as a module without type=module attribute?

@domenic
Copy link
Collaborator

domenic commented Aug 1, 2016

I think that would be weird, personally. I hope we are able to come up with reasonable semantics for both classic and module scripts, inside an import.

@matthewp
Copy link

matthewp commented Aug 1, 2016

I don't think that's what this bug is about. I think the author is suggesting a way for an imported document to define exports, so that instead of calling customElements.define in a script within the import, you might instead export a custom element class that the consumer could then call customElements.define with.

Skipping past the hard parts of integrating the HTML import and ES module systems, let's say that was figured out, it would be nice if you could do something like:

import tabsDocument from './tabs.html';

const Tabs = tabsDocument.exports.default;

customElements.define('my-tabs', Tabs);

@TakayoshiKochi
Copy link
Member

Let's continue this on #645.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants