Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

Typeahead can not work on IE 8 due to Array.indexof function can not work on ie 8 ("HOT_KEYS.indexOf(evt.which) === -1"); #799

Closed

Description

@greengerong

I fix it with ECMAScript 5 code(https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf), like this:

   if (!Array.prototype.indexOf) {
     Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
    'use strict';
    if (this == null) {
      throw new TypeError();
    }
    var n, k, t = Object(this),
        len = t.length >>> 0;

    if (len === 0) {
      return -1;
    }
    n = 0;
    if (arguments.length > 1) {
      n = Number(arguments[1]);
      if (n != n) { // shortcut for verifying if it's NaN
        n = 0;
      } else if (n != 0 && n != Infinity && n != -Infinity) {
        n = (n > 0 || -1) * Math.floor(Math.abs(n));
      }
    }
    if (n >= len) {
      return -1;
    }
    for (k = n >= 0 ? n : Math.max(len - Math.abs(n), 0); k < len; k++) {
      if (k in t && t[k] === searchElement) {
        return k;
      }
    }
    return -1;
  };
}

Activity

  1. hallister commented on Aug 10, 2013

    @hallister

    See #249 which I believe solves all of the IE 8 compatibility issues with Angular, including this one.

  2. pkozlowski-opensource commented on Aug 12, 2013

    @pkozlowski-opensource
    Member

    We are not going to include code for the ES5 backward compatibility as:

    • excellent shims already exist for this purpose, we are recommending this one: https://github.com/kriskowal/es5-shim
    • including shim for non-es5 browsers would increase the library size and would penalize users of modern browsers

    In short: include the mentioned shim in a browser if you need non-es5 browsers support. You can even include it from a CDN: http://cdnjs.com/

  3. Nininea-zz commented on Sep 24, 2014

    @Nininea-zz

    Hey @pkozlowski-opensource ,

    I have imported es5-shim and es5-sham, but in ie8 type still error for typeahead . can yout help me?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions