toddmotto / echo

Lazy-loading images with data-* attributes

Home Page:http://toddmotto.com/labs/echo

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

root.addEventListener is not a function

mr-xiao opened this issue · comments

root.addEventListener is not a function

I'm also running into this issue when I am updating my app to use Webpack. I am using the ES6 import to include the npm package I installed.

import echo from "echo-js";

Also got this issue not using es6 import but with webpack

Hi @zlokomatic @kentjas1
I have the same issue with webpack. What is the solution ?

@pierre-dickinson It's probably due to this and webpack bundling in 'strict mode' as this may be undefined and therefore throw an error as addEventListener won't exist:

https://github.com/toddmotto/echo/blob/master/dist/echo.js#L12

You can change the this to window and that should solve it.