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

Fix for Browserify / similar require #30

Merged
merged 2 commits into from
Mar 27, 2016
Merged

Fix for Browserify / similar require #30

merged 2 commits into from
Mar 27, 2016

Conversation

fuhrysteve
Copy link

Hi @ulion! Looking at this I don't know if it has been working properly since 2012. Anyways, this seems to fix it for me and the module works with browserify now (if you leak jquery to the global scope like so):

since underscore is explicitly defined as null if it is undefined, we should check for whether it is null rather than if it is undefined again.

For context, please see:

((typeof _ !== 'undefined') ? _ : null),

Thanks!

since underscore is explicitly defined as null if it is undefined,
we should check for whether it is null rather than if it is undefined
again.
@ulion
Copy link
Owner

ulion commented Mar 27, 2016

That 2 places, just check "!_" would be better imo.

@fuhrysteve
Copy link
Author

To clarify, do you mean change this

if (serverside && _ === null) {

to this?

if (serverside && !_) {

@ulion
Copy link
Owner

ulion commented Mar 27, 2016

and also the 3rd line since this line.

2016-03-27 19:49 GMT+08:00 Stephen J. Fuhry notifications@github.com:

To clarify, do you mean change this

if (serverside && _ === null) {

to this?

if (serverside && !_) {


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#30 (comment)

Ulion

and just check for truthiness on underscore
@fuhrysteve
Copy link
Author

Ok, I made the truthiness change.

Looking closer at that third line - I don't think it's possible for it to ever get run unless _ is a module, and that module is also undefined - which might not even be possible.

Additionally, it appears that if require('_') fails, that it raises an exception - so that line shouldn't get executed either if underscore is not present.

Further - even if that line did get run, it doesn't look like it will work as designed since the line is missing typeof _

Thanks again, and what do you think, @ulion?

@ulion ulion merged commit 048acee into ulion:dev Mar 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants