-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinserted-text-tag.js
52 lines (40 loc) · 1.24 KB
/
inserted-text-tag.js
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
const template = document.createElement('template');
template.innerHTML = `
<style>
/* Uncomment and provide a URL if you want to import an external stylesheet */
/* @import url(); */
:host {
/* for the shadow root */
display: block;
}
:host(inserted-text-tag) {
/* if my shadow root is inserted-text-tag */
}
:host-context(main) {
/* if one of my ancestors is main */
}
::slotted(*) {
/* anything that is slotted */
}
.inserted-text-tag {}
</style>
<ins class="inserted-text-tag" part="inserted-text-tag"></ins>
`;
class InsertedTextTag extends HTMLElement {
constructor() {
super();
this.root = this.attachShadow({ mode: 'closed' });
this.root.innerHTML = template.innerHTML;
}
// Define allowed attributes
static get observedAttributes() {
return [];
}
// Handle values and changes to the attributes
attributeChangedCallback(_attrName, _oldVal, _newVal) {
// Handle attribute changes here if needed
}
}
customElements.define('inserted-text-tag', InsertedTextTag);
// <inserted-text-tag id='some id'>
// </inserted-text-tag>