Array includes polyfill breaks enonic

Enonic version: 6.5.1
OS: Mac

I tried using the polyfill from this page:

Which led me to render exception, due to property does not exist on object errors.
Thing is I logged the object so I know the property did exist.

I have worked around this by making a normal function instead of adding prototype. And voila no more error.

I’m thinking something like this happens:

  1. There is no array.includes in Ecmascript 5
  2. I add it via polyfill (checking first that I don’t replace it, if its already there)
  3. Enonic also want to add a polyfill, but since mine already exist, use that.
  4. My array.includes polyfill does not work inside Enonic

Single item arrays in Enonic XP automagically returns as strings. Are you first of all making sure you’re not looking at a string here?

About polyfilling I’ll leave that for some backends-guys to answer =)

Well if I was looking at a string then I should get the error that “string” does not have method includes.

I know this doesn’t really answer your original question, but is there any reason you cannot use the good old .indexOf, or even .filter from Ecmascript 5, instead of .includes? Is there more stuff in the polyfills that you need, besides includes?