-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
50 lines (43 loc) · 1.35 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<html>
<head>
<title>HTML Template Element polyfill test</title>
<script src="html-template-polyfill.js"></script>
</head>
<body>
<h1>HTML Template Element Polyfill</h1>
<template id="static">
<output class="static">static template OK</output>
</template>
<div id="output">
</div>
<p>This polyfill is intended to enable template.content properti in Safari.</p>
<script>
window.addEventListener('DOMContentLoaded', function(){
var staticTemplate = document.querySelector('template');
var output = document.querySelector('#output');
var tests = {
staticTemplate: function() {
output.appendChild(staticTemplate.content.cloneNode(true));
if(!output.querySelector('.static')) {
output.appendChild('static template FAILURE');
}
},
dynamicTemplate: function() {
var dynamicTemplate = document.createElement('template');
dynamicTemplate.innerHTML = '<output class="dynamic">dynamic template OK</output>';
document.body.appendChild(dynamicTemplate);
window.requestAnimationFrame(function(){
output.appendChild(dynamicTemplate.content.cloneNode(true));
if(!output.querySelector('.dynamic')) {
output.appendChild('dynamic template FAILURE');
}
});
}
};
Object.getOwnPropertyNames(tests).forEach(function(name) {
tests[name]();
})
});
</script>
</body>
</html>