MCPcopy
hub / github.com/angular/angular / getFirstBoundElement

Function getFirstBoundElement

packages/forms/signals/src/field/validation.ts:416–427  ·  view source on GitHub ↗
(error: ValidationError.WithFieldTree)

Source from the content-addressed store, hash-verified

414}
415
416function getFirstBoundElement(error: ValidationError.WithFieldTree) {
417 if (error.formField) return error.formField.element;
418 return error
419 .fieldTree()
420 .formFieldBindings()
421 .reduce<HTMLElement | undefined>((el: HTMLElement | undefined, binding) => {
422 if (!el || !binding.element) return el ?? binding.element;
423 return el.compareDocumentPosition(binding.element) & Node.DOCUMENT_POSITION_PRECEDING
424 ? binding.element
425 : el;
426 }, undefined);
427}
428
429/**
430 * Compares the position of two validation errors by the position of their corresponding field

Callers 1

compareErrorPositionFunction · 0.85

Calls 3

reduceMethod · 0.80
formFieldBindingsMethod · 0.80
fieldTreeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…