Michael, please take a look at ECMAScript specification, section 7.9 - "Automatic Semicolon Insertion":

http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-262.pdf

This is not an error but a feature. The only case where this could lead to some problem is code like this:

var l = variable.length
(function(){alert('a')})()

In this case, if we miss the semicolon, this would be interpreted as:

var l = variable.length(function(){alert('a')})()

You get the point. But this is only to mention that it is ok to not put the semicolons at the end of the line. I barely put them when writing Javascript...

About repeated variable names, I didn't find any case. Could you point me one? Remember that you can define the same variable multiple times in different scopes, such as functions. This is no problem.

But I'll take the chance to discuss another issue I've just opened yesterday on Github:

http://github.com/rails/jquery-ujs/issues#issue/11

It would be great if the jQuery driver supported including the CSRF token in all AJAX post calls, such as "$.load(url, {data: sample})".

What do you think?

Rodrigo.

Em 02-07-2010 07:27, [email protected] escreveu:
Hi,

Just a comment.

I just had a brief look at rails.js (latest Rails 3 master) and
immediately noticed some really ugly errors like an accidental global
variable (no "var" statement for it) and re-declaration of variables
(more than one "var" statement for the same variable in the same
function), not to mention several forrgotten line-ending semi-colons.
Sure, it _works_, but would it be too much to ask to put such
"official" framework JS files, which thousands of people end up using,
through something like jslint(.com) for at least some basic syntax
checks?

Also, is there a higher-level description of the intentions behind the
JS infrastructure? I've been a little reluctant to start working on it
from just the sources. Okay, it really isn't very complicated, but
addinng/chaning something is easier when one knows the intentions of
those who designed that stuff :-)  For example, I don't know
immediately know what's there to support legacy code, nor what
features are supposed to be implemented by the "modern" JS
infrastructure. To me "modern" means all JS code is in .js files, and
data between server and browser is transferred using JSON(P) or XML,
but no inline-eval of JS code received through an XHR request (evil!)
nor of HTML. It's not obvious if my idea is the same as that of the
Rails development team, or if they/you take a more pragmatical view(?)
and also want to support those last two things as part of the "modern"
Rails 3 JS infrastructure, and not just for legacy support.

Anyway, in general I haven't heard/read much about the JS stuff in
Rails 3 after some initial general announcements, while one can read
so much more about the Rails 3 mailer, router, activemodel, query
builder - the "core" Rails stuff. The JS infrastructure does not seem
to get all that much attention(???).

Thanks.


PS: I would like to add YUI3 support (meaning "I'd like to DO it", and
not "I'd like to ask for it"). I would not bother with supporting the
inline legacy JS code and helpers though.


--
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to