-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathi-do-not-like-web-components.html
More file actions
80 lines (61 loc) · 1.57 KB
/
i-do-not-like-web-components.html
File metadata and controls
80 lines (61 loc) · 1.57 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>I do not like Web Components</title>
<link
rel="stylesheet"
href="https://esm.sh/jsr/@celine/celine@4.8.0/cell.css" />
<link
rel="stylesheet"
href="https://esm.sh/jsr/@celine/libertine@10.0.0/libertine.css" />
</head>
<body>
<main>
<h1>I do not like Web Components</h1>
<p>
I have recently had the displeasure of using Web Components
</p>
<h2>The shadow DOM always encapsulates CSS</h2>
<p>
</p>
<h2>The lifecycle is inscrutable</h2>
<script class="echo">class MyComponent extends HTMLElement {
constructor() {
super();
const shadow = this.attachShadow({mode: 'open'});
shadow.innerHTML = `
<style>
p {
color: red;
}
</style>
<p>Hello, world!</p>
`;
}
connectedCallback() {
console.log('connected');
}
get foo() {
return 'foo';
}
}
const el = document.createElement('my-component');
console.log("foo", el.foo);
console.log(el instanceof MyComponent);
customElements.define('my-component', MyComponent);
console.log("foo", el.foo);
console.log(el instanceof MyComponent);
customElements.whenDefined('my-component').then(() => {
console.log('defined');
console.log("foo", el.foo);
console.log(el instanceof MyComponent);
});
// document.getElementsByTagName('main')[0].appendChild(el);
// console.log("foo", el.foo);
// console.log(el instanceof MyComponent);
</script>
</main>
</body>
</html>