-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinline.html
40 lines (36 loc) · 987 Bytes
/
inline.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Web Component - Inline</title>
</head>
<body>
<my-dialog></my-dialog>
<template id="my-dialog">
<div class="container">
<div class="mask"></div>
<div class="inner">
<h3 class="title">test</h3>
<p class="content"></p>
<button class="cancel"></button>
<button class="confirm"></button>
<button class="close"></button>
</div>
</div>
</template>
<script type="module">
const importDoc = document;
class Dialog extends HTMLElement {
constructor() {
super();
const shadowRoot = this.attachShadow({
mode: 'open',
});
const template = importDoc.getElementById('my-dialog');
shadowRoot.appendChild(template.content.cloneNode(true));
}
}
window.customElements.define('my-dialog', Dialog);
</script>
</body>
</html>