Last active
March 2, 2023 23:08
-
-
Save deebloo/65e2ef3b9bb93e469f56dfc4b0ede334 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MySelectElement extends HTMLElement { | |
constructor() { | |
super(); | |
const observer = new MutationObserver((records) => { | |
for (let record of records) { | |
this.addItem(record.addedNodes); | |
this.removeItem(record.removedNodes); | |
} | |
}); | |
customElements.whenDefined("my-option").then(() => { | |
this.addItems(this.children); | |
observer.observe(this, { childList: true }); | |
}); | |
} | |
addItems(nodes: Iterable<MyOptionElement>) {} | |
removeItems(nodes: Iterable<MyOptionElement>) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment