This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
If a Custom Element is defined via an < element > tag that's loaded via a web component (< link rel="component" >), it's typical to want to treat resource paths as relative to the loading document, the web component. In that case, it's inconvenient for a custom element to load external resources. For example: this.querySelector('img').src = 'images/icon.png'; Here, the 'images' folder is sibling to the web component. If the web component is not sibling to the host document, the image url will be incorrect. It's possible to address this with the following code, but even with URL (https://dvcs.w3.org/hg/url/raw-file/tip/Overview.html), this is inconvenient: < element ... > < script > var baseUrl = this.ownerDocument.URL; // ... var prototype = { updateImage: function() { this.querySelector('img').src = new URL('images/icon.png', baseUrl); } } ... Is there an easier way to accomplish the above? If not, please consider adding a helper api to facilite this relatively common case. Perhaps CustomElements could be given a 'definitionURL' property to avoid the need to capture this information.
*** This bug has been marked as a duplicate of bug 19870 ***