Aos: Uncaught TypeError: this.each is not a function [with Prototype]

Created on 21 Feb 2019  路  3Comments  路  Source: michalsnik/aos

This is:

  • Bug

Specifications

  • Browsers (All)

Steps to Reproduce the Problem


  1. add Prototype JS into project
  2. try to run demo and look into browser console.

Detailed Description

I tried to use this in my magento project but it is have problem with prototypeJs, as you already knows magento is using prototype JS for all JS stuff. i did solve jQuery conflict problem but this shouldn't cause any problem as i can see it's simple javascript. i will appriciate if anybody can solve this issue or guide me into right direction.

Most helpful comment

Hi @junaidfarooqui

Try adding this to a custom js file:

    if ('NodeList' in window) {
        if (!NodeList.prototype.each && NodeList.prototype.forEach) {
            NodeList.prototype.each = NodeList.prototype.forEach;
        }
    }

It's a workaround since prototype.js changes the default behavior.
I had the same issue and was able to fix with this.

All 3 comments

There are no usages of the string this.each in this codebase, so your problem is probably somewhere else.

Hi @patrick-mcdougle, Yeah the error actually showing in a prototype.js file. but as I mentioned I need to use this lib in magento, so somehow it's conflicting with prototype. may be you can try to add this cdn file into project and see the error.

https://cdnjs.cloudflare.com/ajax/libs/prototype/1.7.3/prototype.js

Hi @junaidfarooqui

Try adding this to a custom js file:

    if ('NodeList' in window) {
        if (!NodeList.prototype.each && NodeList.prototype.forEach) {
            NodeList.prototype.each = NodeList.prototype.forEach;
        }
    }

It's a workaround since prototype.js changes the default behavior.
I had the same issue and was able to fix with this.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndTheGodsMadeLove picture AndTheGodsMadeLove  路  3Comments

Dsmol1 picture Dsmol1  路  3Comments

noisypope picture noisypope  路  4Comments

jodriscoll picture jodriscoll  路  4Comments

timotheegoguely picture timotheegoguely  路  3Comments