This repository was archived by the owner on Mar 13, 2018. It is now read-only.
File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -155,15 +155,22 @@ function makeDocument(resource, url) {
155155 var doc = resource ;
156156 if ( ! ( doc instanceof Document ) ) {
157157 doc = document . implementation . createHTMLDocument ( IMPORT_LINK_TYPE ) ;
158- // install html
159- doc . body . innerHTML = resource ;
160158 }
161159 // cache the new document's source url
162160 doc . _URL = url ;
163161 // establish a relative path via <base>
164162 var base = doc . createElement ( 'base' ) ;
165163 base . setAttribute ( 'href' , document . baseURI || document . URL ) ;
166164 doc . head . appendChild ( base ) ;
165+ // install HTML last as it may trigger CustomElement upgrades
166+ // TODO(sjmiles): problem wrt to template boostrapping below,
167+ // template bootstrapping must (?) come before element upgrade
168+ // but we cannot bootstrap templates until they are in a document
169+ // which is too late
170+ if ( ! ( resource instanceof Document ) ) {
171+ // install html
172+ doc . body . innerHTML = resource ;
173+ }
167174 // TODO(sorvell): ideally this code is not aware of Template polyfill,
168175 // but for now the polyfill needs help to bootstrap these templates
169176 if ( window . HTMLTemplateElement && HTMLTemplateElement . bootstrap ) {
You can’t perform that action at this time.
0 commit comments