{"record":{"id":"ab503d05069f3ae0","repo":"twbs/bootstrap","slug":"no-method-named-config-ab503d","errorCode":null,"errorMessage":"No method named \"${config}\"","messagePattern":"No method named \"(.+?)\"","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"js/src/collapse.js","lineNumber":267,"sourceCode":"    for (const element of triggerArray) {\n      element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen)\n      element.setAttribute('aria-expanded', isOpen)\n    }\n  }\n\n  // Static\n  static jQueryInterface(config) {\n    const _config = {}\n    if (typeof config === 'string' && /show|hide/.test(config)) {\n      _config.toggle = false\n    }\n\n    return this.each(function () {\n      const data = Collapse.getOrCreateInstance(this, _config)\n\n      if (typeof config === 'string') {\n        if (typeof data[config] === 'undefined') {\n          throw new TypeError(`No method named \"${config}\"`)\n        }\n\n        data[config]()\n      }\n    })\n  }\n}\n\n/**\n * Data API implementation\n */\n\nEventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {\n  // preventDefault only for <a> elements (which change the URL) not inside the collapsible element\n  if (event.target.tagName === 'A' || (event.delegateTarget && event.delegateTarget.tagName === 'A')) {\n    event.preventDefault()\n  }\n","sourceCodeStart":249,"sourceCodeEnd":285,"githubUrl":"https://github.com/twbs/bootstrap/blob/6177d5f8497f2c08f9874f5221fd17ce5acd2ad7/js/src/collapse.js#L249-L285","documentation":"Collapse's jQueryInterface has a special preprocessing step: when the string is 'show' or 'hide', it merges {toggle: false} into the config before creating the instance, then invokes the string as a method. The guard here is the weakest of all components — it only checks typeof data[config] === 'undefined', with no '_'/'constructor' filtering. Public methods are show, hide, toggle and dispose.","triggerScenarios":"$('#collapse').collapse('toogle') (typo for toggle); $('#collapse').collapse('open') or 'close' (the vocabulary is show/hide); $('#collapse').collapse('expandAll'); any dynamic name that is not exactly show, hide, toggle or dispose.","commonSituations":"Server-rendered templates using open/close wording; developers mixing data-bs-toggle attributes with programmatic calls; typos in wrapper libraries (Rails/Turbo, Livewire helpers) that forward string commands.","solutions":["Use the actual methods: show, hide, toggle, dispose.","Fix typos — note the vocabulary is show/hide, not open/close.","Check the name before dispatch: typeof bootstrap.Collapse.getInstance(el)?.[name] === 'function'.","Use the vanilla API (bootstrap.Collapse.getOrCreateInstance(el).toggle()) for dynamic call sites."],"exampleFix":"// before\n$('#collapse').collapse('toogle') // TypeError: No method named \"toogle\"\n\n// after\n$('#collapse').collapse('toggle') // public methods: show | hide | toggle | dispose","handlingStrategy":"validation","validationCode":"function callCollapseMethod(element, method) {\n  const instance = bootstrap.Collapse.getOrCreateInstance(element)\n  if (typeof instance[method] !== 'function') {\n    console.warn(`Collapse: ignoring unknown method \"${method}\"`)\n    return\n  }\n  instance[method]()\n}","typeGuard":"const COLLAPSE_METHODS = ['show', 'hide', 'toggle', 'dispose'] as const\ntype CollapseMethod = (typeof COLLAPSE_METHODS)[number]\nconst isCollapseMethod = (m: string): m is CollapseMethod =>\n  (COLLAPSE_METHODS as readonly string[]).includes(m)","tryCatchPattern":"try {\n  $('#collapse').collapse(method)\n} catch (err) {\n  if (err instanceof TypeError && err.message.startsWith('No method named')) {\n    console.warn(`Collapse: unknown method \"${method}\"`)\n  } else {\n    throw err\n  }\n}","preventionTips":["Map UI vocabulary to Bootstrap's: open→show, close→hide.","Remember 'show'/'hide' strings also set toggle:false in the created instance's config.","Whitelist dynamic commands to show|hide|toggle|dispose.","Prefer bootstrap.Collapse.getOrCreateInstance(el).toggle()."],"tags":["bootstrap","collapse","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"}