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

Function shouldIgnoreRecord

src/cdk/observers/observe-content.ts:31–52  ·  view source on GitHub ↗
(record: MutationRecord)

Source from the content-addressed store, hash-verified

29// infinite change detection cycles where the change detection updates a comment, triggering the
30// MutationObserver, triggering another change detection and kicking the cycle off again.
31function shouldIgnoreRecord(record: MutationRecord) {
32 // Ignore changes to comment text.
33 if (record.type === 'characterData' && record.target instanceof Comment) {
34 return true;
35 }
36 // Ignore addition / removal of comments.
37 if (record.type === 'childList') {
38 for (let i = 0; i < record.addedNodes.length; i++) {
39 if (!(record.addedNodes[i] instanceof Comment)) {
40 return false;
41 }
42 }
43 for (let i = 0; i < record.removedNodes.length; i++) {
44 if (!(record.removedNodes[i] instanceof Comment)) {
45 return false;
46 }
47 }
48 return true;
49 }
50 // Observe everything else.
51 return false;
52}
53
54/**
55 * Factory that creates a new MutationObserver and allows us to stub it out in unit tests.

Callers 1

observeMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected