mozilla/pdf.js · error · Error

Not enough parameters.

Error message

Not enough parameters.

What it means

Thrown by OverlayManager.register when the dialog argument is not an object (typeof dialog !== 'object'). The method requires an HTMLDialogElement to track in its WeakMap. Note typeof null === 'object', so null slips past this guard; the check effectively rejects undefined and primitives.

Source

Thrown at web/overlay_manager.js:34

class OverlayManager {
  #overlays = new WeakMap();

  #active = null;

  get active() {
    return this.#active;
  }

  /**
   * @param {HTMLDialogElement} dialog - The overlay's DOM element.
   * @param {boolean} [canForceClose] - Indicates if opening the overlay closes
   *                  an active overlay. The default is `false`.
   * @returns {Promise} A promise that is resolved when the overlay has been
   *                    registered.
   */
  async register(dialog, canForceClose = false) {
    if (typeof dialog !== "object") {
      throw new Error("Not enough parameters.");
    } else if (this.#overlays.has(dialog)) {
      throw new Error("The overlay is already registered.");
    }
    this.#overlays.set(dialog, { canForceClose });

    dialog.addEventListener("cancel", ({ target }) => {
      if (this.#active === target) {
        this.#active = null;
      }
    });
  }

  /**
   * @param {HTMLDialogElement} dialog - The overlay's DOM element.
   * @returns {Promise} A promise that is resolved when the overlay has been
   *                    opened.
   */
  async open(dialog) {

View on GitHub (pinned to 5903d58d58)

Solutions

  1. Ensure the HTMLDialogElement exists in the DOM before calling register.
  2. Pass the actual element reference: const dialog = document.getElementById('myDialog'); await OverlayManager.register(dialog);
  3. If the element may be absent, guard with an explicit null check before registering.

Example fix

// before
OverlayManager.register(maybeMissingRef);

// after
const dialog = document.getElementById('passwordDialog');
if (dialog instanceof HTMLDialogElement) {
  await OverlayManager.register(dialog);
}
Defensive patterns

Strategy: validation

Validate before calling

const dialog = document.getElementById('myDialog');
if (dialog instanceof HTMLDialogElement) {
  await OverlayManager.register(dialog);
}

Type guard

function isDialogEl(v) {
  return v instanceof HTMLDialogElement;
}

Prevention

When it happens

Trigger: Calling register() with no argument (dialog is undefined), a string, number, boolean, or symbol. E.g. overlayManager.register() or overlayManager.register(document.querySelector('#missing')).

Common situations: Selector returned null/undefined because the dialog element was not yet in the DOM, typo in element id, or calling register before DOMContentLoaded.

Related errors


AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13). Data as JSON: /api/errors/2216b5c50aece65f. Report an issue: GitHub.