Skip to content
This repository has been archived by the owner on May 17, 2021. It is now read-only.

Fix undefined error in browser when compiled with Babel #144

Merged
merged 52 commits into from
Jun 29, 2018

Conversation

williamukoh
Copy link

Provides a fallback for script to still work in browser, after compiling with Babel. Babel converts this to undefined

Olical and others added 30 commits December 3, 2015 10:39
Execute listeners in the order they are added
Reverses order of listener execution, so now they're executed in the order they are added.
Documentation: type='text/javascript' is not needed in HTML5
Also add default "this" since things like phantomjs can whine about it.
Fix IIFE so webpack / babel works again
Update API docs and lock dependencies
Webpack fails to find the file and my build procedure crashes.
Remove array in main property of bower.json.
@Olical
Copy link
Owner

Olical commented Jun 29, 2018

I was wondering why there were so many commits then I realised you targeted develop which I had forgotten about 😅 so you've updated develop for me I guess. Also didn't realise this was an issue, why is this not defined when you use babel + browser? I guess it gets wrapped in some object or function call that screws with it?

@williamukoh
Copy link
Author

Was just following your instructions Sir! --> Contributing (aim your pull request at the develop branch!)

It was kinda strange to me at first. I was using a gulp-babel setup to compile source JS files and noticed anytime I tried new EventEmitter(), I kept getting undefined. So I copied your source code https://github.com/Olical/EventEmitter/blob/master/EventEmitter.js and pasted into https://babeljs.io/repl/, and noticed argument passed to the self-executing anonymous function was changed from this || {} to undefined || {}

@Olical
Copy link
Owner

Olical commented Jun 29, 2018

Yup, I know :D it's not a problem at all, just forgot it was that way. I'll update those things to how I like to do things now, thanks for reminding me.

I think I see your issue though and I think this fix is fine? I just hope it doesn't break it for anyone else. I'm guessing you have tried this version and it's all okay?

@Olical Olical merged commit 4c9f346 into Olical:develop Jun 29, 2018
@williamukoh
Copy link
Author

Yes I have. And it works fine. Doesn't break anything over here ;)

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

Successfully merging this pull request may close these issues.

8 participants