Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
tweak order of operations so that document._url is available at eleme…
Browse files Browse the repository at this point in the history
…nt upgrade time when using imports dynamically
  • Loading branch information
Scott J. Miles committed Oct 4, 2013
1 parent 78cb8b6 commit 5eb2f21
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/HTMLImports.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,22 @@ function makeDocument(resource, url) {
var doc = resource;
if (!(doc instanceof Document)) {
doc = document.implementation.createHTMLDocument(IMPORT_LINK_TYPE);
// install html
doc.body.innerHTML = resource;
}
// cache the new document's source url
doc._URL = url;
// establish a relative path via <base>
var base = doc.createElement('base');
base.setAttribute('href', document.baseURI || document.URL);
doc.head.appendChild(base);
// install HTML last as it may trigger CustomElement upgrades
// TODO(sjmiles): problem wrt to template boostrapping below,
// template bootstrapping must (?) come before element upgrade
// but we cannot bootstrap templates until they are in a document
// which is too late
if (!(resource instanceof Document)) {
// install html
doc.body.innerHTML = resource;
}
// TODO(sorvell): ideally this code is not aware of Template polyfill,
// but for now the polyfill needs help to bootstrap these templates
if (window.HTMLTemplateElement && HTMLTemplateElement.bootstrap) {
Expand Down

0 comments on commit 5eb2f21

Please sign in to comment.