{"record":{"id":"99ad6c0802c9871b","repo":"twbs/bootstrap","slug":"no-method-named-config","errorCode":null,"errorMessage":"No method named \"${config}\"","messagePattern":"No method named \"(.+?)\"","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"js/src/alert.js","lineNumber":67,"sourceCode":"\n  // Private\n  _destroyElement() {\n    this._element.remove()\n    EventHandler.trigger(this._element, EVENT_CLOSED)\n    this.dispose()\n  }\n\n  // Static\n  static jQueryInterface(config) {\n    return this.each(function () {\n      const data = Alert.getOrCreateInstance(this)\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\nenableDismissTrigger(Alert, 'close')\n\n/**\n * jQuery\n */\n\ndefineJQueryPlugin(Alert)","sourceCodeStart":49,"sourceCodeEnd":85,"githubUrl":"https://github.com/twbs/bootstrap/blob/6177d5f8497f2c08f9874f5221fd17ce5acd2ad7/js/src/alert.js#L49-L85","documentation":"Alert's jQuery bridge (installed by defineJQueryPlugin) turns $('.alert').alert('method') into a dynamic lookup of that method on the Alert instance. jQueryInterface first verifies the string resolves on the instance, does not start with '_', and is not 'constructor'; otherwise it throws this TypeError. Alert exposes only two public methods — close and the inherited dispose — so every other string is rejected.","triggerScenarios":"$('.alert').alert('show') (Alert has no show); $('.alert').alert('destory') (typo for dispose); $('.alert').alert('_element') or $('.alert').alert('constructor') (explicitly rejected by the guard); $('.alert').alert(nameFromDataset) where the method name comes from unvalidated data attributes or URL parameters.","commonSituations":"Copy-pasting calls written for a different component (Modal's 'show' used on an alert); simple typos; dynamic dispatch driven by user input; migrating from Bootstrap v4 where the jQuery API existed too but method names differed (v4 'destroy' became v5 'dispose').","solutions":["Call one of Alert's public methods: 'close' or 'dispose'.","Fix the typo — verify the name against the methods table in the Bootstrap 5.3 Alert docs.","If the name is dynamic, whitelist it first: typeof instance[name] === 'function' && !name.startsWith('_') && name !== 'constructor'.","Prefer the vanilla API: bootstrap.Alert.getInstance(el)?.close() degrades to undefined instead of throwing."],"exampleFix":"// before\n$('.alert').alert('disposeAll') // TypeError: No method named \"disposeAll\"\n\n// after\n$('.alert').alert('close')      // public methods on Alert: close | dispose","handlingStrategy":"validation","validationCode":"function callAlertMethod(element, method) {\n  const instance = bootstrap.Alert.getOrCreateInstance(element)\n  const callable = typeof instance[method] === 'function' &&\n    !method.startsWith('_') && method !== 'constructor'\n  if (!callable) {\n    console.warn(`Alert: ignoring unknown method \"${method}\"`)\n    return\n  }\n  instance[method]()\n}","typeGuard":"const ALERT_METHODS = ['close', 'dispose'] as const\ntype AlertMethod = (typeof ALERT_METHODS)[number]\nconst isAlertMethod = (m: string): m is AlertMethod =>\n  (ALERT_METHODS as readonly string[]).includes(m)","tryCatchPattern":"try {\n  $('.alert').alert(method)\n} catch (err) {\n  if (err instanceof TypeError && err.message.startsWith('No method named')) {\n    console.warn(`Alert: unknown method \"${method}\"`)\n  } else {\n    throw err\n  }\n}","preventionTips":["Whitelist method names before dispatch; never interpolate raw input into $(...).alert(name).","Learn the v5 vocabulary: close/dispose here (not open/close/destroy).","Prefer bootstrap.Alert.getInstance(el)?.close() — undefined instead of a throw.","Names starting with '_' and 'constructor' are always rejected."],"tags":["bootstrap","alert","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"}