Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FakeRest throws Array.findIndex() error while using it on IE and Edge #25

Open
ashwanikumar415 opened this issue Jul 10, 2017 · 5 comments

Comments

@ashwanikumar415
Copy link

Included fakeRest via npm in project . But now when the same app runs on IE or Edge throws the below error:
Object doesn't support property or method 'findIndex' File: FakeRest.min.js, Line: 1, Column: 14642
Was this intentional not to support IE ?

@fzaninotto
Copy link
Member

No, it's IE's lack of support for modern JS that is intentional ;)

@ashwanikumar415
Copy link
Author

Well in that case , only workaround left is to use below polyfill and load it before fakeRest in html

` if (!Array.prototype.findIndex) {
Object.defineProperty(Array.prototype, 'findIndex', {

value: function(predicate) {
  if (this == null) {
    throw new TypeError('"this" is null or not defined');
  }
  var o = Object(this);
  var len = o.length >>> 0;
  if (typeof predicate !== 'function') {
    throw new TypeError('predicate must be a function');
  }
  var thisArg = arguments[1];
  var k = 0;
  while (k < len) {
    var kValue = o[k];
    if (predicate.call(thisArg, kValue, k, o)) {
      return k;
    }
    k++;
  }
  return -1;
}

});
} `

@ashwanikumar415
Copy link
Author

ashwanikumar415 commented Jul 11, 2017

@fzaninotto
Is it feasible to add the above-mentioned piece of polyfill in your code? So that fake rest runs everywhere flawlessly? And consumers of fakeRest don't have to bother to add polyfill just to make it work?
The error is thrown from : https://github.com/marmelab/FakeRest/blob/master/src/Collection.js

@fzaninotto
Copy link
Member

Of course! Would you like to make a Pull Request?

@ashwanikumar415
Copy link
Author

@fzaninotto
sure !!! that'll be great . We install fakeRest via npm in our project

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants