{"record":{"id":"647824cca46fac51","repo":"twbs/bootstrap","slug":"no-method-named-config-647824","errorCode":null,"errorMessage":"No method named \"${config}\"","messagePattern":"No method named \"(.+?)\"","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"js/src/offcanvas.js","lineNumber":220,"sourceCode":"        this.hide()\n        return\n      }\n\n      EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED)\n    })\n  }\n\n  // Static\n  static jQueryInterface(config) {\n    return this.each(function () {\n      const data = Offcanvas.getOrCreateInstance(this, config)\n\n      if (typeof config !== 'string') {\n        return\n      }\n\n      if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {\n        throw new TypeError(`No method named \"${config}\"`)\n      }\n\n      data[config](this)\n    })\n  }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {\n  const target = SelectorEngine.getElementFromSelector(this)\n\n  if (['A', 'AREA'].includes(this.tagName)) {\n    event.preventDefault()\n  }\n","sourceCodeStart":202,"sourceCodeEnd":238,"githubUrl":"https://github.com/twbs/bootstrap/blob/6177d5f8497f2c08f9874f5221fd17ce5acd2ad7/js/src/offcanvas.js#L202-L238","documentation":"Offcanvas's jQueryInterface applies the strict guard — the method must exist on the instance, must not start with '_', and must not be 'constructor' — and calls data[config](this), passing the DOM element through (offcanvas show accepts a relatedTarget). Public methods are show, hide, toggle and dispose.","triggerScenarios":"$('#offcanvas').offcanvas('open') or 'close'; $('#offcanvas').offcanvas('_element') or 'constructor' (explicitly rejected); $('#offcanvas').offcanvas('display'); any guessed verb other than show, hide, toggle, dispose.","commonSituations":"The open/close vocabulary feels natural for offcanvas/sidebars, but Bootstrap uses show/hide; wrapper components (React/Vue offcanvas libs) forwarding wrong command strings; typos in dynamic dispatch.","solutions":["Use show, hide, toggle or dispose.","Replace open/close vocabulary: open → show, close → hide.","Never pass names starting with '_' or the literal 'constructor'.","For dynamic calls, prefer bootstrap.Offcanvas.getOrCreateInstance(el).show()."],"exampleFix":"// before\n$('#offcanvas').offcanvas('open') // TypeError: No method named \"open\"\n\n// after\n$('#offcanvas').offcanvas('show') // show | hide | toggle | dispose","handlingStrategy":"validation","validationCode":"function callOffcanvasMethod(element, method) {\n  const instance = bootstrap.Offcanvas.getOrCreateInstance(element)\n  const callable = typeof instance[method] === 'function' &&\n    !method.startsWith('_') && method !== 'constructor'\n  if (!callable) {\n    console.warn(`Offcanvas: ignoring unknown method \"${method}\"`)\n    return\n  }\n  instance[method](element)\n}","typeGuard":"const OFFCANVAS_METHODS = ['show', 'hide', 'toggle', 'dispose'] as const\ntype OffcanvasMethod = (typeof OFFCANVAS_METHODS)[number]\nconst isOffcanvasMethod = (m: string): m is OffcanvasMethod =>\n  (OFFCANVAS_METHODS as readonly string[]).includes(m)","tryCatchPattern":"try {\n  $('#offcanvas').offcanvas(method)\n} catch (err) {\n  if (err instanceof TypeError && err.message.startsWith('No method named')) {\n    console.warn(`Offcanvas: unknown method \"${method}\"`)\n  } else {\n    throw err\n  }\n}","preventionTips":["Use show/hide, not open/close, for offcanvas commands.","This component's guard also rejects '_' names and 'constructor' outright.","Whitelist dynamic drawer commands at the call site.","Prefer bootstrap.Offcanvas.getOrCreateInstance(el).show()."],"tags":["bootstrap","offcanvas","jquery","typeerror","method-dispatch"],"backgroundTag":"invalid-method-name","analyzedSha":"6177d5f8497f2c08f9874f5221fd17ce5acd2ad7","analyzedAt":"2026-08-22T03:20:03.375Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}