Skip to content

Commit

Permalink
Fixes IE11 test issues
Browse files Browse the repository at this point in the history
Use <template>.innerHTML when adding test elements to main document. Works around a template polyfill issue (webcomponents/template#40) by setting innerHTML on a <template> element so that inner templates are correctly updated.
  • Loading branch information
Steven Orvell committed Apr 30, 2018
1 parent 48a8483 commit 8b5803c
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 68 deletions.
4 changes: 2 additions & 2 deletions test/unit/custom-style-async-import.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Polymer } from '../../lib/legacy/polymer-fn.js';

const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<custom-style>
<style is="custom-style">
Expand All @@ -24,7 +24,7 @@ $_documentContainer.innerHTML = `<custom-style>
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);

Polymer({
is: 'x-client'
Expand Down
4 changes: 2 additions & 2 deletions test/unit/custom-style-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
*/

import './sub/style-import.js';
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.setAttribute('style', 'display: none;');

$_documentContainer.innerHTML = `<dom-module id="shared-style">
Expand Down Expand Up @@ -42,4 +42,4 @@ $_documentContainer.innerHTML = `<dom-module id="shared-style">
</style>
</custom-style>`;

document.head.appendChild($_documentContainer);
document.head.appendChild($_documentContainer.content);
112 changes: 56 additions & 56 deletions test/unit/custom-style.html
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
See: https://github.com/Polymer/polymer-modulizer/issues/154
-->
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<custom-style>
<style is="custom-style">
Expand Down Expand Up @@ -79,10 +79,10 @@
</style>
</custom-style>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<custom-style>
<style is="custom-style">
Expand Down Expand Up @@ -113,11 +113,11 @@
</style>
</custom-style>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<custom-style>
<style is="custom-style" include="shared-style2">
Expand All @@ -132,10 +132,10 @@
</style>
</custom-style>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<custom-style>
<style is="custom-style">
Expand All @@ -147,100 +147,100 @@
</style>
</custom-style>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="italic">italic</div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="bag">bag</div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="mix">mix</div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="dynamic">dynamic</div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="import-mixin">import-mixin</div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="import-var">import-var</div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<x-bar></x-bar>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<x-foo></x-foo>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<x-red-text></x-red-text>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<x-blue-bold-text></x-blue-bold-text>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<parent-variable-with-var></parent-variable-with-var>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<br>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script><script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<br>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>
<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div id="after"></div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="foo"></div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.innerHTML = `<div class="foo--bar"></div>`;
document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="x-baz">
<template>
Expand All @@ -253,11 +253,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="x-bar">
<template>
Expand All @@ -271,11 +271,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="x-foo">
<template>
Expand All @@ -302,11 +302,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="x-red-text">
<template>
Expand All @@ -319,11 +319,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="x-blue-bold-text">
<template>
Expand All @@ -334,11 +334,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="parent-variable-with-var">
<template>
Expand All @@ -359,11 +359,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="child-variable-with-var">
<template>
Expand All @@ -387,11 +387,11 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');

$_documentContainer.innerHTML = `<dom-module id="child-of-child-with-var">
<template>
Expand All @@ -410,7 +410,7 @@
</template>
</dom-module>`;

document.body.appendChild($_documentContainer);
document.body.appendChild($_documentContainer.content);
</script>

<script type="module">
Expand Down
4 changes: 2 additions & 2 deletions test/unit/shady-unscoped-style-import.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.setAttribute('style', 'display: none;');

$_documentContainer.innerHTML = `<dom-module id="global-shared1">
Expand All @@ -33,4 +33,4 @@ $_documentContainer.innerHTML = `<dom-module id="global-shared1">
</dom-module><dom-module id="global-shared2">
</dom-module>`;

document.head.appendChild($_documentContainer);
document.head.appendChild($_documentContainer.content);
4 changes: 2 additions & 2 deletions test/unit/styling-import-shared-styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Code distributed by Google as part of the polymer project is also
subject to an additional IP rights grant found at http://polymer.github.io/PATENTS.txt
*/

const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.setAttribute('style', 'display: none;');

$_documentContainer.innerHTML = `<dom-module id="shared-styles">
Expand All @@ -28,4 +28,4 @@ $_documentContainer.innerHTML = `<dom-module id="shared-styles">
</template>
</dom-module>`;

document.head.appendChild($_documentContainer);
document.head.appendChild($_documentContainer.content);
4 changes: 2 additions & 2 deletions test/unit/sub/resolveurl-elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import { DomModule } from '../../../lib/elements/dom-module.js';
import { Polymer } from '../../../lib/legacy/polymer-fn.js';
import { pathFromUrl } from '../../../lib/utils/resolve-url.js';

const $_documentContainer = document.createElement('div');
const $_documentContainer = document.createElement('template');
$_documentContainer.setAttribute('style', 'display: none;');
const baseAssetPath = pathFromUrl(import.meta.url);
$_documentContainer.innerHTML = `<dom-module id="p-r-ap" assetpath="${baseAssetPath}../../assets/"></dom-module>`;
document.head.appendChild($_documentContainer);
document.head.appendChild($_documentContainer.content);

class PR extends PolymerElement {
static get template() {
Expand Down
4 changes: 2 additions & 2 deletions test/unit/sub/style-import.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { pathFromUrl } from '../../../lib/utils/resolve-url.js';

const $_documentContainer = document.createElement('div');
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}">
Expand All @@ -23,4 +23,4 @@ $_documentContainer.innerHTML = `<dom-module id="style-import" assetpath="${base
</template>
</dom-module>`;

document.head.appendChild($_documentContainer);
document.head.appendChild($_documentContainer.content);

0 comments on commit 8b5803c

Please sign in to comment.