mirror of
https://github.com/Polymer/polymer.git
synced 2025-02-25 18:55:30 -06:00
Use <template>.innerHTML when adding test elements to main document. Works around a template polyfill issue (https://github.com/webcomponents/template/issues/40) by setting innerHTML on a <template> element so that inner templates are correctly updated.
27 lines
741 B
JavaScript
27 lines
741 B
JavaScript
import { pathFromUrl } from '../../../lib/utils/resolve-url.js';
|
|
|
|
const $_documentContainer = document.createElement('template');
|
|
$_documentContainer.setAttribute('style', 'display: none;');
|
|
const baseAssetPath = pathFromUrl(import.meta.url);
|
|
$_documentContainer.innerHTML = `<dom-module id="style-import" assetpath="${baseAssetPath}">
|
|
<template>
|
|
<style>
|
|
.foo {
|
|
height: 2px;
|
|
border: 1px solid orange;
|
|
background: url(google.png);
|
|
}
|
|
</style>
|
|
</template>
|
|
</dom-module><dom-module id="style-import2" assetpath="${baseAssetPath}">
|
|
<template>
|
|
<style>
|
|
.foo {
|
|
width: 4px;
|
|
}
|
|
</style>
|
|
</template>
|
|
</dom-module>`;
|
|
|
|
document.head.appendChild($_documentContainer.content);
|