MCPcopy Create free account
hub / github.com/angular/components / startObserving

Method startObserving

src/aria/private/utils/collection.ts:40–59  ·  view source on GitHub ↗
(element: HTMLElement)

Source from the content-addressed store, hash-verified

38 }
39
40 startObserving(element: HTMLElement) {
41 this.stopObserving();
42 this._observer = new MutationObserver(mutations => {
43 const hasStructuralChange = mutations.some(m => m.addedNodes.length || m.removedNodes.length);
44
45 if (hasStructuralChange) {
46 const newItems = this._getSortedItems();
47 const currentItems = this._sortedItems();
48 const hasChanged =
49 newItems.length !== currentItems.length ||
50 newItems.some((item, index) => currentItems[index] !== item);
51
52 if (hasChanged) {
53 this._sortedItems.set(newItems);
54 }
55 }
56 });
57
58 this._observer.observe(element, {childList: true, subtree: true, attributes: false});
59 }
60
61 stopObserving() {
62 this._observer?.disconnect();

Callers 11

constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80
constructorMethod · 0.80

Calls 4

stopObservingMethod · 0.95
_getSortedItemsMethod · 0.95
setMethod · 0.80
observeMethod · 0.45

Tested by 1

constructorMethod · 0.64