Closed fuhrysteve closed 8 years ago
That 2 places, just check "!_" would be better imo.
To clarify, do you mean change this
if (serverside && _ === null) {
to this?
if (serverside && !_) {
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 https://github.com/ulion/jsonform/pull/30#issuecomment-202047552
Ulion
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?
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: https://github.com/ulion/jsonform/blob/e590a02ce6729458fdb564da065e2095c923531e/lib/jsonform.js#L4472
Thanks!