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

Function compareErrorPosition

packages/forms/signals/src/field/validation.ts:435–444  ·  view source on GitHub ↗

* Compares the position of two validation errors by the position of their corresponding field * binding directive in the DOM. * - For errors with multiple field bindings, the earliest one in the DOM will be used for comparison. * - For errors that have no field bindings, they will be considered t

(
  a: ValidationError.WithFieldTree,
  b: ValidationError.WithFieldTree,
)

Source from the content-addressed store, hash-verified

433 * - For errors that have no field bindings, they will be considered to come after all other errors.
434 */
435function compareErrorPosition(
436 a: ValidationError.WithFieldTree,
437 b: ValidationError.WithFieldTree,
438): number {
439 const aEl = getFirstBoundElement(a);
440 const bEl = getFirstBoundElement(b);
441 if (aEl === bEl) return 0;
442 if (aEl === undefined || bEl === undefined) return aEl === undefined ? 1 : -1;
443 return aEl.compareDocumentPosition(bEl) & Node.DOCUMENT_POSITION_PRECEDING ? 1 : -1;
444}

Callers

nothing calls this directly

Calls 1

getFirstBoundElementFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…