-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.html
More file actions
51 lines (42 loc) · 884 Bytes
/
Copy pathtest.html
File metadata and controls
51 lines (42 loc) · 884 Bytes
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
<!DOCTYPE html>
<html>
<head>
<title>Web Component</title>
</head>
<body>
<h1>Web Component</h1>
<my-app></my-app>
</body>
<script>
const template = document.createElement('template');
template.innerHTML = `
<style>
:host {
display: block;
font-family: sans-serif;
text-align: center;
}
span {
cursor: pointer;
}
ul {
list-style: none;
padding: 0;
}
</style>
<h1>My App</h1>
<input type="text" placeholder="Add a new to do"></input>
<span>✍</span>
<ul id="todos"></ul>
`;
class MyApp extends HTMLElement {
constructor() {
super();
this._shadowRoot = this.attachShadow({ 'mode': 'open' });
this._shadowRoot.appendChild(template.content.cloneNode(true));
this.$todoList = this._shadowRoot.querySelector('ul');
}
}
window.customElements.define('my-app', MyApp);
</script>
</html>