{"record":{"id":"2216b5c50aece65f","repo":"mozilla/pdf.js","slug":"not-enough-parameters","errorCode":null,"errorMessage":"Not enough parameters.","messagePattern":"Not enough parameters\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"web/overlay_manager.js","lineNumber":34,"sourceCode":"class OverlayManager {\n  #overlays = new WeakMap();\n\n  #active = null;\n\n  get active() {\n    return this.#active;\n  }\n\n  /**\n   * @param {HTMLDialogElement} dialog - The overlay's DOM element.\n   * @param {boolean} [canForceClose] - Indicates if opening the overlay closes\n   *                  an active overlay. The default is `false`.\n   * @returns {Promise} A promise that is resolved when the overlay has been\n   *                    registered.\n   */\n  async register(dialog, canForceClose = false) {\n    if (typeof dialog !== \"object\") {\n      throw new Error(\"Not enough parameters.\");\n    } else if (this.#overlays.has(dialog)) {\n      throw new Error(\"The overlay is already registered.\");\n    }\n    this.#overlays.set(dialog, { canForceClose });\n\n    dialog.addEventListener(\"cancel\", ({ target }) => {\n      if (this.#active === target) {\n        this.#active = null;\n      }\n    });\n  }\n\n  /**\n   * @param {HTMLDialogElement} dialog - The overlay's DOM element.\n   * @returns {Promise} A promise that is resolved when the overlay has been\n   *                    opened.\n   */\n  async open(dialog) {","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/mozilla/pdf.js/blob/5903d58d58e4dd9ce6ffa3834aea8480f06b4ada/web/overlay_manager.js#L16-L52","documentation":"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.","triggerScenarios":"Calling register() with no argument (dialog is undefined), a string, number, boolean, or symbol. E.g. overlayManager.register() or overlayManager.register(document.querySelector('#missing')).","commonSituations":"Selector returned null/undefined because the dialog element was not yet in the DOM, typo in element id, or calling register before DOMContentLoaded.","solutions":["Ensure the HTMLDialogElement exists in the DOM before calling register.","Pass the actual element reference: const dialog = document.getElementById('myDialog'); await OverlayManager.register(dialog);","If the element may be absent, guard with an explicit null check before registering."],"exampleFix":"// before\nOverlayManager.register(maybeMissingRef);\n\n// after\nconst dialog = document.getElementById('passwordDialog');\nif (dialog instanceof HTMLDialogElement) {\n  await OverlayManager.register(dialog);\n}","handlingStrategy":"validation","validationCode":"const dialog = document.getElementById('myDialog');\nif (dialog instanceof HTMLDialogElement) {\n  await OverlayManager.register(dialog);\n}","typeGuard":"function isDialogEl(v) {\n  return v instanceof HTMLDialogElement;\n}","tryCatchPattern":null,"preventionTips":["Resolve the element after DOMContentLoaded.","Pass element references, not selectors or null.","Type-check the argument before calling register."],"tags":["overlay","dom","validation","ui-utils"],"backgroundTag":null,"analyzedSha":"5903d58d58e4dd9ce6ffa3834aea8480f06b4ada","analyzedAt":"2026-08-13T02:28:27.364Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}