(element: HTMLElement)
| 44 | } |
| 45 | |
| 46 | startObserving(element: HTMLElement) { |
| 47 | if (this._observer) { |
| 48 | this._observer.disconnect(); |
| 49 | } |
| 50 | |
| 51 | this._observer = new MutationObserver(mutations => { |
| 52 | const hasStructuralChange = mutations.some(m => m.addedNodes.length || m.removedNodes.length); |
| 53 | if (hasStructuralChange) { |
| 54 | this._version.update(v => v + 1); |
| 55 | } |
| 56 | }); |
| 57 | |
| 58 | this._observer.observe(element, {childList: true, subtree: true}); |
| 59 | } |
| 60 | |
| 61 | stopObserving() { |
| 62 | this._observer?.disconnect(); |