MCPcopy Index your code
hub / github.com/angular/angular / isRelevantSelectMutation

Function isRelevantSelectMutation

packages/forms/signals/src/directive/select.ts:53–80  ·  view source on GitHub ↗

* Checks if a given mutation record is relevant for resyncing a . * In general its relevant if: * - Non comment content of the select changed * - The value attribute of an option changed.

(mutation: MutationRecord)

Source from the content-addressed store, hash-verified

51 * - The value attribute of an option changed.
52 */
53function isRelevantSelectMutation(mutation: MutationRecord) {
54 // Consider changes that may add / remove options, or change their text content.
55 if (mutation.type === 'childList' || mutation.type === 'characterData') {
56 // If the target element is a comment it's not relevant.
57 if (mutation.target instanceof Comment) {
58 return false;
59 }
60 // Otherwise if any non-comment nodes were added / removed it is relevant.
61 for (const node of mutation.addedNodes) {
62 if (!(node instanceof Comment)) {
63 return true;
64 }
65 }
66 for (const node of mutation.removedNodes) {
67 if (!(node instanceof Comment)) {
68 return true;
69 }
70 }
71 // Otherwise it's not relevant.
72 return false;
73 }
74 // If the value attribute of an option changed, it's relevant.
75 if (mutation.type === 'attributes' && mutation.target instanceof HTMLOptionElement) {
76 return true;
77 }
78 // Everything else is not relevant.
79 return false;
80}

Callers 1

observeSelectMutationsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…