{"record":{"id":"f9b23623c557899e","repo":"dianping/cat","slug":"function-prototype-bind-what-is-trying-to-be-bou","errorCode":null,"errorMessage":"Function.prototype.bind - what is trying to be bound is not callable","messagePattern":"Function\\.prototype\\.bind - what is trying to be bound is not callable","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"cat-home/src/main/webapp/assets/js/uncompressed/html5shiv.js","lineNumber":332,"sourceCode":"  /*--------------------------------------------------------------------------*/\n\n  // expose html5\n  window.html5 = html5;\n\n  // shiv the document\n  shivDocument(document);\n\n}(this, document));\n\n\n\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind#Compatibility\n// IE function.bind polyfill\nif (!Function.prototype.bind) {\n  Function.prototype.bind = function (oThis) {\n    if (typeof this !== \"function\") {\n      // closest thing possible to the ECMAScript 5 internal IsCallable function\n      throw new TypeError(\"Function.prototype.bind - what is trying to be bound is not callable\");\n    }\n\n    var aArgs = Array.prototype.slice.call(arguments, 1), \n        fToBind = this, \n        fNOP = function () {},\n        fBound = function () {\n          return fToBind.apply(this instanceof fNOP && oThis\n                                 ? this\n                                 : oThis,\n                               aArgs.concat(Array.prototype.slice.call(arguments)));\n        };\n\n    fNOP.prototype = this.prototype;\n    fBound.prototype = new fNOP();\n\n    return fBound;\n  };\n}","sourceCodeStart":314,"sourceCodeEnd":350,"githubUrl":"https://github.com/dianping/cat/blob/e815e74d4c2dd74edac831241f1253fcc7d25381/cat-home/src/main/webapp/assets/js/uncompressed/html5shiv.js#L314-L350","documentation":"html5shiv ships the MDN Function.prototype.bind polyfill for old IE. Per the (now obsolete) spec draft it throws a TypeError when .bind is called on a non-function — i.e. some code did notTheFn.bind(...) or a function reference was undefined/overwritten. In a polyfilled IE8 environment this is nearly always 'undefined is not a function' manifesting through bind on an undefined variable or host object.","triggerScenarios":"someVar.bind(...) where someVar is undefined because the defining script failed to load or ran later; binding a non-function property (obj.method missing); feature-detection code doing X.bind on IE8 host objects that report typeof 'object'.","commonSituations":"Legacy IE support pages where a plugin script 404'd leaving globals undefined; third-party widgets calling .bind on optional callbacks; event handler maps referencing renamed functions.","solutions":["Inspect the stack to find which variable .bind was called on, then ensure it is defined before that code runs (script order / 404s).","Guard optional callbacks: if (cb && typeof cb === 'function') cb = cb.bind(ctx);","Add typeof checks before binding host objects in IE-specific code paths."],"exampleFix":"// before\nvar handler = window.MyWidget.onEvent.bind(ctx); // MyWidget failed to load\n\n// after\nif (window.MyWidget && typeof MyWidget.onEvent === 'function') {\n  var handler = MyWidget.onEvent.bind(ctx);\n}","handlingStrategy":"type-guard","validationCode":"function bindSafe(fn, ctx) {\n  return (typeof fn === 'function') ? fn.bind(ctx) : null;\n}\nvar handler = bindSafe(window.MyWidget && MyWidget.onEvent, ctx);","typeGuard":"function isCallable(v) { return typeof v === 'function'; }","tryCatchPattern":null,"preventionTips":["Check typeof x === 'function' before any .bind call on optional/global references.","Fix script load failures (404s/order) that leave globals undefined in legacy IE pages.","Prefer addEventListener/feature checks over binding host objects on IE8."],"tags":["html5shiv","bind","polyfill","ie","undefined-reference"],"backgroundTag":null,"analyzedSha":"e815e74d4c2dd74edac831241f1253fcc7d25381","analyzedAt":"2026-08-14T14:22:34.512Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}