odyniec / imgareaselect

ImgAreaSelect is a jQuery plugin for selecting a rectangular area of an image. It allows web developers to easily implement image cropping functionality, as well as other user interface features, such as photo notes (like those on Flickr).
http://odyniec.net/projects/imgareaselect/
686 stars 197 forks source link

if (o = options.borderWidth) #18

Closed paazmaya closed 12 years ago

paazmaya commented 12 years ago

Line 921 has the following line:

if (o = options.borderWidth)

Perhaps it should be == instead of =

AaronLasseigne commented 12 years ago

The line is correct. It will set o and return the value from options.borderWidth so the if can check it. It's the same as:

o = options.borderWidth
if (o)
  $handles.css({ borderWidth: o, borderStyle: 'solid' });
paazmaya commented 12 years ago

Would it make sense for readability to change the line to the one you commented in the reply?

AaronLasseigne commented 12 years ago

Perhaps, but I think that's subjective. I suspect odyniec (the author) likes the style he's used. It would be up to him to change it.

odyniec commented 12 years ago

Actually, I'm using constructs like this to save a few bytes here and there (this can make a significant difference when the code gets packed/minified). I usually prefer cleaner code, like the one that @AaronLasseigne demonstrated :-)