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.

有帮助吗?

解决方案 2

you can add a style tag with an @import directive

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

其他提示

<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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top