Michael Peters wrote:
RobG wrote:
>
> Michael Peters wrote:
>> [EMAIL PROTECTED] wrote:
>> > Hello,
>> >
>> > I've noticed that when you put a ',' at the end of the last effect, IE
>> > doesn't work.
>>
>> It doesn't work because it's not really correct.
>
> Not correct in what way?  It is legal ECMAScript syntax, however it is
> interpreted incorrectly by IE which will add an extra element to the
> array.  Therefore it may be "not correct" because Effect.Parallel
> expects all elements in the array to have been assigned a value.

I'm sorry, I was a little confused. I thought you were talking about trailing
commas in object literals.

  {
    stuff : 'foo',
    more  : 'bar',
  }

Am I mistaken, or are those allowed too?

Elisions (empty elements) aren't allowed in object literals.  However,
I recall someone suggesting trailing commas in object literals be
tolerated and not throw an error as a proposal for JavaScript 2.0,
though I can't find a reference for it right now.

The purpose of elisions in Array literals is to provide a short-cut
method of incrementing the length without creating empty elements,
e.g.:

 var x = [];
 x[2] = 'foo';

should be identical to:

 var x = [ ,,'foo' ];

That is, an array with length 3 and a single element at index 2.  IE
gets this example right, however there is a known bug in Gecko browsers
where elisions not at the end are created as elements and given the
value 'undefined'.  In Firefox the second example above creates an
array with length 3, elements at index 0 and 1 with value 'undefined'
and at index 2 with value 'foo'.

With trailing elisions, the last one should have no effect: Gecko gets
that bit right, but IE doesn't:

 var x = [ 'foo',, ];

Should result in x having a length of 2 and a single element 'foo' at
index 0.  Firefox gets the length right but has an 'undefined' element
at index 1.  IE correctly doesn't add elided elements but gets the
length wrong, setting it to 3.



> In this regard, ECMAScript is consistent with those "other languages" -
> it is IE's flawed implementation of the specification that is the
> difference.

I'm not trying to defend IE or say that other browsers should break conformance
with the spec to accomodate MS. I was just mistaken. Sorry for the confusion.

That's OK.  Probably the most ECMAScript compliant browser is Opera.
When using a large and complex library (or a bunch of them in the case
of Prototype + Scriptaculous) across a variety of browsers it is often
difficult to tell whether code execution errors are the result of a
browser's ECMAScript non-conformance or some quirk of the library.
Most browsers are very compliant, but there is the occasional gotcha.


--
Rob


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on 
Rails: Spinoffs" 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-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to