-
Notifications
You must be signed in to change notification settings - Fork 11.9k
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
TypeError: node.addEventListener is not a function #5998
Comments
We don't override
That's already the case if you use our UMD build ( Anyway, I'm not against renaming our local methods |
Huh, interesting! Thanks for the clarification, @simonbrunel! Is there any way to get rollup to separate scope automatically? I'm rather new to using a JS build system :P I see. Looks like importing According to #5978 that you've linked to, |
|
Cool, thanks :-) |
Thanks so much, @simonbrunel 😺 |
Thanks @kurkle actually :) |
Expected Behavior
I should be able to use
window.addEventListener
as normal.Current Behavior
Chart.JS overrides
window.addEventListener()
with a completely different implementation with a different method signature!Possible Solution
Wrap Chart.JS (and all sub-files!) in a SEAF (self-executing anonymous function) to avoid polluting the global scope.
Steps to Reproduce (for bugs)
An 'live demo' is not useful here. Instead, I can provide detailed steps to reproduce, and a link tot he commit in the source tree of my open-source project: https://github.com/ConnectedHumber/Air-Quality-Web/tree/4a9d67e2924edc511bca1b0530a3370a3b20af5d (note that there
may beprobably are additional commits after this, so if yougit clone
you'll want togit checkout
the exact commit).Chart.JS
I've got an
index.mjs
like this:"use strict";
...the Chart.JS
import
is buried in the application. It looks like this (in one of the sub-files):I get the following output from
rollup
on the command-line:The error in the Firefox Developer Tools comes with a stack trace. Here it is:
.....that
platform.dom.js
is part of Chart.JS. As I have source maps enabled, it tells me where that file is located:http://[::1]:40482/node_modules/chart.js/src/platforms/platform.dom.js
Context
I'm using Rollup as my build system to create a dynamic map (with LeafletJS) of some data. Line graphs are a part of this - so, after a quick search of npm, I decided to bring in Chart.JS to do the heavy lifting with respect to displaying the graphs etc. Unfortunately, this had an adverse affect on the rest of my application because Chart.JS pollutes the global scope.
Environment
The text was updated successfully, but these errors were encountered: