{"record":{"id":"44c31dc5fc7b5206","repo":"pentaho/pentaho-kettle","slug":"typeerror","errorCode":null,"errorMessage":"TypeError","messagePattern":"TypeError","errorType":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/shim/es5.js","lineNumber":33,"sourceCode":"/* ES5 polyfills */\n\n/* eslint no-extend-native: 0 */\n\n// Add trim function to support IE8\nif(typeof String.prototype.trim !== \"function\") {\n  String.prototype.trim = function() {\n    return this.replace(/^\\s+|\\s+$/g, \"\");\n  };\n}\n\n// Add indexOf function to support IE8\nif(!Array.prototype.indexOf) {\n  Array.prototype.indexOf = function(searchElement /*, fromIndex */) {\n\n    \"use strict\";\n\n    if(this == null) {\n      throw new TypeError();\n    }\n\n    var n, k, t = Object(this),\n        len = t.length >>> 0;\n\n    if(len === 0) {\n      return -1;\n    }\n\n    n = 0;\n    if(arguments.length > 1) {\n      n = Number(arguments[1]);\n      if(n != n) { // shortcut for verifying if it's NaN\n        n = 0;\n      } else if(n != 0 && n != Infinity && n != -Infinity) {\n        n = (n > 0 || -1) * Math.floor(Math.abs(n));\n      }\n    }","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/shim/es5.js#L15-L51","documentation":"The ES5 Array.prototype.indexOf polyfill implements the spec: if `this` is null or undefined (the method is called on null/undefined or as a bare function), it throws a bare TypeError, per ECMA-262 15.4.4.14.","triggerScenarios":"Calling [].indexOf.call(null, x) or [].indexOf.apply(undefined, args); invoking the polyfilled function detached on a null this in strict mode (the polyfill's 'use strict' means this is not coerced to global).","commonSituations":"Generic array-method reuse (Array.prototype.slice/indexOf tricks) with a null first argument; legacy code running on old browsers (IE8) where the polyfill is actually active and receives null from a helper.","solutions":["Guard the receiver: if(arr) idx = arr.indexOf(x).","When using indexOf.call, pass a real array-like object as the first argument.","Default null receivers to an empty array before searching."],"exampleFix":"// before\nvar i = Array.prototype.indexOf.call(maybeNull, item);\n// after\nvar i = maybeNull ? maybeNull.indexOf(item) : -1;","handlingStrategy":"type-guard","validationCode":"if (arr == null) return -1;\nvar idx = arr.indexOf(item);","typeGuard":"function isSearchable(x) { return x != null && typeof x.length === 'number'; }","tryCatchPattern":"try { i = arr.indexOf(item); } catch (e) { if (e instanceof TypeError) { i = -1; } else throw e; }","preventionTips":["Null-check arrays before generic method calls like indexOf.call.","Default null receivers to [] in helper utilities.","Remember strict-mode functions do not coerce null `this` to the global object."],"tags":["es5","polyfill","array","typeerror","null-this"],"backgroundTag":"null-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}