-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
96 lines (87 loc) · 2.72 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title><juicy-dom-tree-view></title>
<!-- Importing Web Component's Polyfill -->
<script src="../webcomponentsjs/webcomponents-lite.js"></script>
<!-- Importing Custom Elements -->
<link rel="import" href="juicy-dom-tree-view.html">
<style>
.examples{
display: flex;
}
.examples > div{
flex:1;
padding: 0.5em;
}
#shadow-host{
border: 1px solid lightgrey;
}
</style>
</head>
<body class="markdown-body">
<div class="examples">
<div>
<h3><code><juicy-dom-tree-view></code></h3>
<!-- Runs custom element -->
<juicy-dom-tree-view></juicy-dom-tree-view>
</div>
<div>
<h3><code><juicy-dom-tree-view multiple></code></h3>
<juicy-dom-tree-view multiple></juicy-dom-tree-view>
</div>
<div>
<h3><code><juicy-dom-tree-view fake-v1></code></h3>
<juicy-dom-tree-view fake-v1></juicy-dom-tree-view>
</div>
<div>
<h3><code><juicy-dom-tree-view fake-v1 wrapped-content></code></h3>
<juicy-dom-tree-view fake-v1 wrapped-content></juicy-dom-tree-view>
</div>
</div>
<div class="examples">
<div>
<h3>Element which Shadow DOM will be displayed in tree</h3>
<div id="shadow-host">
<p slot="App/0">Some</p>
<span slot="App/1">Content</span>
<div slot="App/defined-slot-name">
Blah
</div>
</div>
</div>
<div>
<h3>Shadow DOM code</h3>
<pre><code id="shadow-code">
</code></pre>
</div>
</div>
<script>
(function(){
let host = document.querySelector('#shadow-host');
let tree = document.querySelectorAll('juicy-dom-tree-view');
let shadow = `<h2>Shadow DOM</h2>
<div style="display: hidden;">
<slot name="App/0"></slot>
</div>
<slot name="App/1"></slot>
<div style="display: flex; justify-content: flex-end;" content-wrapper>
<slot name="App/defined-slot-name"></slot>
</div>
shadow's inline text`;
document.querySelector('#shadow-code').innerHTML = shadow.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>');
let sr = null;
if (host.attachShadow) {
sr = host.attachShadow({ mode: 'open' });
} else {
sr = host.createShadowRoot();
}
sr.innerHTML = shadow;
Array.prototype.forEach.call(tree, function(tree){
tree.doc = sr;
});
}());
</script>
</body>
</html>