Array.prototype.find() (and probably findIndex()) compatibility hazard

# Till Schneidereit (12 years ago)

Just as with the recent addition of Array.prototype.values(), we're running into problems with Array.prototype.find()1.

Asana uses an internal framework called "Luna" that contains an "IIterable". This defines[2][3], among others, find and findIndex functions with signatures that aren't compatible with the ones specified in ES6. That causes the entire application to not work. At all.

I'll try contacting Asana in the hope of them fixing the issue, but this'll probably not be the last issue with find.

[2] d3ki9tyy5l5ruj.cloudfront.net/prod/build/bundles/5e40e508ea86bea48248afec47fb23f8f1100243/apps/asana/bundle.js?cb=1372896568000, lines 3030 - 3044

[3] gist.github.com/anonymous/84cde55714eeee7d24a2 (in case the original link changes)

# Rick Waldron (12 years ago)

Thanks for the report!

I'm also seeing:

  • filter
  • forEach
  • indexOf
  • join
  • map
  • reduce

(From L3024-3074)

It appears that an IIterable is used to create the IVector, which then has its patchClass method called with (built-in) Array (L3205). The patchClass operation is then extending the Array.prototype with all of the custom methods. I've reduced it from the provided code: gist.github.com/rwldrn/2864ff4b3f804005f370

I'm confident this can be fixed internally with little to no problem (assuming they have adequate tests written to support their codebase)

# Till Schneidereit (12 years ago)

Ah, great, thanks for doing that! The reduced version confirms what I thought was going on: patchClass, patchInstance and addToClass all only add the given function to the given target if a same-named function doesn't already exist. As the other potentially-replaces functions all predate the library, their semantics match.

I'm confident this can be fixed internally with little to no problem (assuming they have adequate tests written to support their codebase)

I very much agree, yes. We only had this in Nightly builds for about a week now, but it's somewhat reassuring that, as of yet, this is the only issue we're aware of with find and findIndex.

# Till Schneidereit (12 years ago)

I forgot to follow up on this: the issue in Asana was fixed on their side last week.

We haven't received any other reports of sites these methods are causing issues for, so it's looking pretty good so far.

# Rick Waldron (12 years ago)

On Tue, Jul 16, 2013 at 5:39 AM, Till Schneidereit < till at tillschneidereit.net> wrote:

I forgot to follow up on this: the issue in Asana was fixed on their side last week.

We haven't received any other reports of sites these methods are causing issues for, so it's looking pretty good so far.

Great news! Thanks for the update :)