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

[Custom Elements] Import module #329

Closed
ParkFramework opened this issue Sep 25, 2015 · 8 comments
Closed

[Custom Elements] Import module #329

ParkFramework opened this issue Sep 25, 2015 · 8 comments

Comments

@ParkFramework
Copy link

It will be very useful to describe the import attribute in custom element.

Example: index.html

<custom-button import="MyClassButton from 'buttons.html'"></custom-button>

Example: buttons.html

<style>
...
</style>
<script>
export class MyClassButton extends HTMLButtonElement
{
   // Synchronous constructor and other API
}
</script>

User agent, automatically loading file and register element.

@rniwa
Copy link
Collaborator

rniwa commented Sep 26, 2015

I think more natural way of doing that will be something like:

<script type="module" src="my-component.js" import="my-button as custom-button">
...
<custom-button>...</custom-button>
<custom-button>...</custom-button>
...

@ParkFramework
Copy link
Author

@rniwa Your offer, there is no import CSS styles, file buttons.html It contains styles and js script.

@rniwa
Copy link
Collaborator

rniwa commented Sep 27, 2015

You can import CSS via @import in your custom element's shadow tree. Since styles are scoped at a shadow boundary, you'd need to include a style element inside your shadow tree anyway.

@ParkFramework
Copy link
Author

Yes, this is to HTML code buttons.html, instead of the JS my-component.js :)

@dglazkov
Copy link
Contributor

BTW, there are pretty serious issues with using @import in Shadow DOM, uncovered by Polymer folks and diagnosed by @tabaktins/@esprehn. For more details, see: https://lists.w3.org/Archives/Public/www-style/2014Aug/0238.html.

@dglazkov
Copy link
Contributor

@tabatkins for realz now.

@rniwa
Copy link
Collaborator

rniwa commented Sep 27, 2015

LOL, it's uncanny that I pointed out style sharing as an issue multiple times in the past, and you guys told me @import (and cache headers) is the solution. It was also one of the reasons we wanted to do CSS-based tree scoping.

But now that we're all here, it would be great to tackle this problem.

@annevk
Copy link
Collaborator

annevk commented Mar 11, 2016

This is a duplicate of #136. @dglazkov I recommend filing a distinct issue for @import if you had not done so yet.

@annevk annevk closed this as completed Mar 11, 2016
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

5 participants