Don't rely on dom-module synchronously until WCR.

This commit is contained in:
Kevin Schaaf
2018-04-05 16:00:54 -07:00
parent 412bb1e019
commit e64bd0ba6f

View File

@@ -34,31 +34,33 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
</template>
</dom-module>
<script>
class PR extends Polymer.Element {
static get is() { return 'p-r'; }
}
customElements.define(PR.is, PR);
class PRImportMeta extends Polymer.Element {
static get template() {
return Polymer.DomModule.import('p-r', 'template').cloneNode(true);
window.addEventListener('WebComponentsReady', () => {
class PR extends Polymer.Element {
static get is() { return 'p-r'; }
}
static get importMeta() {
customElements.define(PR.is, PR);
class PRImportMeta extends Polymer.Element {
static get template() {
return Polymer.DomModule.import('p-r', 'template').cloneNode(true);
}
static get importMeta() {
// Idiomatically, this would be `return import.meta`, but for purposes
// of stubbing the test without actual modules, it's shimmed
return { url: 'http://class.com/mymodule/index.js' };
}
}
customElements.define('p-r-im', PRImportMeta);
const PRHybrid = Polymer({
is: 'p-r-hybrid',
_template: Polymer.DomModule.import('p-r', 'template').cloneNode(true),
// Idiomatically, this would be `return import.meta`, but for purposes
// of stubbing the test without actual modules, it's shimmed
return { url: 'http://class.com/mymodule/index.js' };
}
}
customElements.define('p-r-im', PRImportMeta);
importMeta: { url: 'http://hybrid.com/mymodule/index.js' }
});
const PRHybrid = Polymer({
is: 'p-r-hybrid',
_template: Polymer.DomModule.import('p-r', 'template').cloneNode(true),
// Idiomatically, this would be `return import.meta`, but for purposes
// of stubbing the test without actual modules, it's shimmed
importMeta: { url: 'http://hybrid.com/mymodule/index.js' }
});
</script>
<dom-module id="p-r-ap" assetpath="../../assets/"></dom-module>