{"record":{"id":"750c991368116e96","repo":"OrchardCMS/OrchardCore","slug":"cannot-call-a-class-as-a-function","errorCode":null,"errorMessage":"Cannot call a class as a function","messagePattern":"Cannot call a class as a function","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/popper-1.16.1/popper.js","lineNumber":375,"sourceCode":"\nfunction getSize(axis, body, html, computedStyle) {\n  return Math.max(body['offset' + axis], body['scroll' + axis], html['client' + axis], html['offset' + axis], html['scroll' + axis], isIE(10) ? parseInt(html['offset' + axis]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Top' : 'Left')]) + parseInt(computedStyle['margin' + (axis === 'Height' ? 'Bottom' : 'Right')]) : 0);\n}\n\nfunction getWindowSizes(document) {\n  var body = document.body;\n  var html = document.documentElement;\n  var computedStyle = isIE(10) && getComputedStyle(html);\n\n  return {\n    height: getSize('Height', body, html, computedStyle),\n    width: getSize('Width', body, html, computedStyle)\n  };\n}\n\nvar classCallCheck = function (instance, Constructor) {\n  if (!(instance instanceof Constructor)) {\n    throw new TypeError(\"Cannot call a class as a function\");\n  }\n};\n\nvar createClass = function () {\n  function defineProperties(target, props) {\n    for (var i = 0; i < props.length; i++) {\n      var descriptor = props[i];\n      descriptor.enumerable = descriptor.enumerable || false;\n      descriptor.configurable = true;\n      if (\"value\" in descriptor) descriptor.writable = true;\n      Object.defineProperty(target, descriptor.key, descriptor);\n    }\n  }\n\n  return function (Constructor, protoProps, staticProps) {\n    if (protoProps) defineProperties(Constructor.prototype, protoProps);\n    if (staticProps) defineProperties(Constructor, staticProps);\n    return Constructor;","sourceCodeStart":357,"sourceCodeEnd":393,"githubUrl":"https://github.com/OrchardCMS/OrchardCore/blob/4306c0717fe573f6fca1b4955909ddab6a192807/src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Vendor/popper-1.16.1/popper.js#L357-L393","documentation":"Popper's babel-compiled class guard throws this TypeError when a constructor (here Popper itself, via classCallCheck) is invoked without `new`, so `instance instanceof Constructor` is false. The ES5 transpilation of ES6 classes cannot distinguish a plain function call from construction without this runtime check.","triggerScenarios":"Calling Popper(reference, popper, options) without `new`; passing a bundled/re-exported Popper around in a way that loses construction context; calling an internal compiled class as a function after minification/concatenation mistakes.","commonSituations":"Old tutorial snippets or scripts using Popper 0.x/1.x API without `new`; mixing Popper builds (popper.js vs popper-utils, UMD vs ES) so the wrong export is invoked as a function; Bootstrap wiring where the Popper reference was overwritten.","solutions":["Invoke the constructor with `new`: new Popper(referenceElement, popperElement, options).","If you only need positioning for Bootstrap tooltips/dropdowns, use bootstrap's bundled Popper and remove manual Popper calls.","Verify the imported symbol is the Popper constructor (default export of popper.js), not a helper or utils build.","Consider upgrading to Popper 2 (@popperjs/core), which uses native ES classes and reports `Class constructor cannot be invoked without 'new'` more clearly."],"exampleFix":"// before\nvar popper = Popper(referenceEl, tooltipEl, { placement: 'top' });\n\n// after\nvar popper = new Popper(referenceEl, tooltipEl, { placement: 'top' });","handlingStrategy":"validation","validationCode":"function createPopper(ref, popperEl, options) {\n  if (typeof Popper !== 'function') throw new Error('Popper not loaded');\n  return new Popper(ref, popperEl, options); // always construct with new\n}","typeGuard":"function isPopperInstance(x) { return typeof Popper === 'function' && x instanceof Popper; }","tryCatchPattern":"let instance;\ntry {\n  instance = new Popper(refEl, popEl, { placement: 'bottom' });\n} catch (e) {\n  if (e instanceof TypeError && /class as a function/.test(e.message)) {\n    console.error('Popper must be called with new; check import/build');\n  } else throw e;\n}","preventionTips":["Always instantiate Popper with the `new` operator.","Verify your import resolves to the Popper constructor (correct build: popper.js, not popper-utils).","Use instanceof checks on stored Popper instances before calling methods like .scheduleUpdate().","Consider Popper 2 (@popperjs/core) with native classes and clearer messages."],"tags":["popper","constructor","new-operator","javascript"],"backgroundTag":"invalid-constructor-argument","analyzedSha":"4306c0717fe573f6fca1b4955909ddab6a192807","analyzedAt":"2026-09-13T17:41:05.024Z","contentChangedAt":"2026-09-13T17:41:05.024Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}