Repository: excalidraw/excalidraw
File: packages/excalidraw/data/restore.ts (TypeScript)

Code before:
};

const repairBinding = <T extends ExcalidrawArrowElement>(
  element: T,
  binding: FixedPointBinding | null,
  targetElementsMap: Readonly<ElementsMap>,
  /** used for context (arrow bindings) */
  existingElementsMap: Readonly<ElementsMap> | null | undefined,
  startOrEnd: "start" | "end",
): FixedPointBinding | null => {
  try {
    if (!binding) {
      return null;
    }

    // ---------------------------------------------------------------------------
    // elbow arrows
    // ---------------------------------------------------------------------------

    if (isElbowArrow(element)) {
      const fixedPointBinding:
        | ExcalidrawElbowArrowElement["startBinding"]
        | ExcalidrawElbowArrowElement["endBinding"] = {
        ...binding,
        fixedPoint: normalizeFixedPoint(
          isFixedPoint(binding.fixedPoint) ? binding.fixedPoint : [0, 0],
        ),
        mode: binding.mode || "orbit",
      };

      return fixedPointBinding;
    }

    // ---------------------------------------------------------------------------
    // simple arrows
    // ---------------------------------------------------------------------------

    // binding schema v2
    // ---------------------------------------------------------------------------

    if (binding.mode) {
      // if latest binding schema, don't check if binding.elementId exists
      // (it's done in a separate pass)
      if (binding.elementId) {
        return {
          elementId: binding.elementId,
          mode: binding.mode,
          fixedPoint: normalizeFixedPoint(
            isFixedPoint(binding.fixedPoint) ? binding.fixedPoint : [0.5, 0.5],
          ),
        } as FixedPointBinding | null;

Review comment (suggestion):
if we're already checking `isFixedPoint` inside the `normalizeFixedPoint` then we can keep `normalizeFixedPoint(binding.fixedPoint ?? [0, 0])`

Code after:

const repairBinding = <T extends ExcalidrawArrowElement>(
  element: T,
  binding: FixedPointBinding | null,
  targetElementsMap: Readonly<ElementsMap>,
  /** used for context (arrow bindings) */
  existingElementsMap: Readonly<ElementsMap> | null | undefined,
  startOrEnd: "start" | "end",
): FixedPointBinding | null => {
  try {
    if (!binding) {
      return null;
    }

    // ---------------------------------------------------------------------------
    // elbow arrows
    // ---------------------------------------------------------------------------

    if (isElbowArrow(element)) {
      const fixedPointBinding:
        | ExcalidrawElbowArrowElement["startBinding"]
        | ExcalidrawElbowArrowElement["endBinding"] = {
        ...binding,
        fixedPoint: normalizeFixedPoint(binding.fixedPoint),
        mode: binding.mode || "orbit",
      };

      return fixedPointBinding;
    }

    // ---------------------------------------------------------------------------
    // simple arrows
    // ---------------------------------------------------------------------------

    // binding schema v2
    // ---------------------------------------------------------------------------

    if (binding.mode) {
      // if latest binding schema, don't check if binding.elementId exists
      // (it's done in a separate pass)
      if (binding.elementId) {
        return {
          elementId: binding.elementId,
          mode: binding.mode,
          fixedPoint: normalizeFixedPoint(binding.fixedPoint),
        } as FixedPointBinding | null;
      }
      return null;
    }

    // binding schema v1 (legacy) -> attempt to migrate to v2