Skip to content
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

IFFY wrong root context #13

Closed
NeXTs opened this issue Oct 5, 2016 · 5 comments
Closed

IFFY wrong root context #13

NeXTs opened this issue Oct 5, 2016 · 5 comments

Comments

@NeXTs
Copy link

NeXTs commented Oct 5, 2016

When using dueljs in a merged context (e.g. in a build pipeline merging all javascript files into one bundle (e.g. webpack)), the context will become (suprisingly!) empty object instead of window.

Because of this - plugin breaks during initialization at L425 saying el doesn't have addEventListener method

Using window instead of this resolves issue for me, although maybe there are better solution..

@ghost
Copy link

ghost commented Oct 13, 2016

@NeXTs Ok now I have the same problem as I'm migrating my project to webpack :(

the window context instead of this does indeed fix the problem.

@studentIvan
Copy link
Owner

I just copied the solution from jQuery, now it is gonna be working

(typeof window !== "undefined" ? window : this, function (window) {

@studentIvan
Copy link
Owner

I did test it in this code-style

import duel from 'dueljs'
const ch = duel.channel('test')

@NeXTs
Copy link
Author

NeXTs commented Oct 16, 2016

Cool!
Just checked, everything works as expected.
Great job, thank you! 👍

@ghost
Copy link

ghost commented Oct 17, 2016

Nice @studentIvan 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants