Skip to content

Instantly share code, notes, and snippets.

@deebloo
Last active March 2, 2023 23:08
Embed
What would you like to do?
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