Imports are designed to be relocatable. IOW, I can make an import that uses <img src="foo.png">
and put foo.png
in the same folder as the import, and a project can use that import and have access to the image without fumbling with the paths.
Polymer takes this one step further by (attempting) to make paths inside of templates also import-relative. That way I can put <img src="foo.png">
in my template and have the same behavior as above.
Rewriting of paths in a <polymer-element>
in the main document is a bug. Any path mangling that doesn't result in a correct import-relative path is a bug. Sounds like you hit some bugs here, suggest you file issue tickets.
Additional notes:
Until recently, any url containing bindings was left untouched. I believe the latest version will instead convert such urls to be import-relative, if the url is unambiguously relative in the first place.
If you need to imperatively calculate a path to wherever your element was sourced, you can use the
resolvePath
method that is built-in to every polymer element. IOW, something like this:var documentRelativePathToFoo = this.resolvePath('foo.png');
. This calculates the path tofoo.png
that is correct from the perspective ofwindow.document
, which is the perspective of most DOM operations (e.g. XHR).