[Bug 20976] Define base URLs in DOM

https://www.w3.org/Bugs/Public/show_bug.cgi?id=20976

--- Comment #30 from Mathias Bynens <mathias@qiwi.be> ---
`innerHTML` and similar are not the problem, IMHO. To use relative URLs in
<script>s within HTML imports, use the URL API, e.g.:

    var importBaseURL = document.currentScript.ownerDocument.baseURI;
    var url = new URL('foo.png', importBaseURL).toString();
    // Now, use `url` in `innerHTML` all you want.

The problem that still lacks a good solution: authors want to use things like
`<link rel=stylesheet href=bar>` expecting `bar` to always be relative to the
HTML import that includes it (without having to script it all). Same for
`<img>`, references in `<style>` blocks, etc.

Consider this document, located at
`https://example.com/some-component/import-me.html`:

    <img src=foo>

It would be nice if the import process would *somehow* turn that into…

    <img src=https://example.com/some-component/foo>

…before inserting it into the parent document.

If setting `shadowRoot.baseURI = document.currentScript.ownerDocument.baseURI`
would have this effect, that’d be a fair solution for shadow roots. But IMHO
this is a problem for all imports, regardless of whether they use shadow roots
or not.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.

Received on Friday, 3 October 2014 20:46:26 UTC