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

Add "media" attribute on require for css #278

Open
vbornand opened this issue Mar 17, 2017 · 1 comment
Open

Add "media" attribute on require for css #278

vbornand opened this issue Mar 17, 2017 · 1 comment

Comments

@vbornand
Copy link

vbornand commented Mar 17, 2017

I'm submitting a feature request.

Some libraries provides css files for printing, and ask to add it like this:
<link href="print.css" rel="stylesheet" type="text/css" media="print" />

It should be useful to have an attribute "media" for the require tag to handle this case.

Sample of expected behavior:
<require from="print.css" media="print">

if this feature is accepted by the community, I'm ready to do the analyze of the changes and do them.

@vbornand
Copy link
Author

vbornand commented Mar 22, 2017

I analyzed how the as='scoped' feature and it is managed here:
https://github.com/aurelia/loader/blob/c0cbdbbf42f284559443c7533043c5de859858c8/src/template-registry-entry.js#L78

The "scoped" is used as the name of the dependency, a kind of hack... and handle by the CSSResource class:
CSSResource.prototype.register = function register(registry, name) { if (name === 'scoped') { registry.registerViewEngineHooks(this._scoped); } else { this._global = true; } };

Should I add a property media, to the class TemplateDepency or should I add a new property containing an object (for example named: settings) with different properties to manage other future attributes on the require element?

If we decide to add a settings property, the scoped value should be stored in it, and the as='scoped' should be deprecated, and use <require from="print.css" scoped="on"/> instead or something similar.

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

2 participants