Question

Why can I do

<img _src="/foobar/{{ cssPath }}.jpg">

but not

<link rel="stylesheet" type="text/css" _href="{{ cssPath }}">

The first line replaces the path correctly. In the second line cssPath is null. Does anyone have an idea how to bind to a link's href attribute or is that impossible?

Regards and Thanks Robert

EDIT

Looks like my object gets constructed too late. I defined it globally like this: final themeManager = new ThemeManger._(); But it looks like this is happens too late.

Was it helpful?

Solution 2

you can add a style tag with an @import directive

this.shadowRoot.append(new StyleElement()..text = "@import url('some.css')");

OTHER TIPS

<link rel="stylesheet"> is not support natively in shadow dom, but <style> is. Support stylesheets is a feature Polymer provides on top of the native stuff.

When the element definition is registered, Polymer inlines stylesheets into <style>. You can check this by examining the element' shadow dom in the devtools. This means bindings on the link's href won't work (everything is setup at registration time).

Something like this would be nice to support. I suggest filing a bug.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top