Skip to content

Commit c4568bd

Browse files
author
R. S. Doiel
committed
Added mutation observer setup for a-to-z-list
1 parent bda4bc8 commit c4568bd

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

a-to-z-list.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,23 @@ class AtoZList extends HTMLElement {
99

1010
connectedCallback() {
1111
this.render();
12+
this.setupMutationObserver();
13+
}
14+
15+
setupMutationObserver() {
16+
const observer = new MutationObserver((mutations) => {
17+
mutations.forEach((mutation) => {
18+
if (mutation.type === 'childList' && mutation.addedNodes.length > 0) {
19+
this.render();
20+
}
21+
});
22+
});
23+
24+
observer.observe(this, {
25+
attributes: false,
26+
childList: true,
27+
subtree: true
28+
});
1229
}
1330

1431
render() {

0 commit comments

Comments
 (0)