Skip to content
This repository has been archived by the owner on Sep 20, 2019. It is now read-only.

Commit

Permalink
Merge pull request #483 from webcomponents/hide-template
Browse files Browse the repository at this point in the history
Hide polyfill templates from rendering
  • Loading branch information
dfreedm committed Feb 19, 2016
2 parents d72f57d + f33444f commit 84c6c67
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 75 deletions.
6 changes: 6 additions & 0 deletions src/Template/Template.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@
var contentDoc = document.implementation.createHTMLDocument('template');
var canDecorate = true;

var templateStyle = document.createElement('style');
templateStyle.textContent = TEMPLATE_TAG + '{display:none;}';

var head = document.head;
head.insertBefore(templateStyle, head.firstElementChild);

/**
Provides a minimal shim for the <template> element.
*/
Expand Down
72 changes: 0 additions & 72 deletions tests/Template/html/Template.html

This file was deleted.

23 changes: 20 additions & 3 deletions tests/Template/tests.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@
<script src="../../../web-component-tester/browser.js"></script>
</head>
<body>
<template>
<span id="content">Hello World!</span>
</template>
<style>
.container {
display: flex;
}
.container > *{
flex: 1;
}
</style>

<div class="container">
<template>
<span id="content">Hello World!</span>
</template>
</div>

<script>
suite('Template', function() {
Expand All @@ -26,6 +37,12 @@
template = document.querySelector('template');
});

test('No rendering', function() {
var bcr = template.getBoundingClientRect();
assert.equal(bcr.height, 0);
assert.equal(bcr.width, 0);
});

test('content', function() {
assert.equal(template.childNodes.length, 0, 'template children evacipated');
assert.isDefined(template.content, 'template content exists');
Expand Down

0 comments on commit 84c6c67

Please sign in to comment.