I am creating a web component using native implementation, which in it\'s html template has links to images. However, those links only work if they are absolute, or relative
Reacting on my own prev comment to MarcG answer - the need for the modules to be aware of their own path has become acknowledged and nowadays may be retrieved by the import.meta.url
mean!
So it is much easier to write now some util to fetch component's HTML/CSS.
Furthermore, if CSS is NOT fetched, but a new style sheet link dynamically added to the document - this CSS plays very well with relative paths furthermore.
Having that, today, while waiting for some standard way to specify my component's base url, my ow approach is to provide a component with 2 resources:
fetch
API, turned into template, cached and then cloned into the component each time new instance of it attached to the DOMlink
element