pvdung / ourlibrary

Automatically exported from code.google.com/p/ourlibrary
0 stars 0 forks source link

Array enumeration functions should iterate in ascending order #22

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

// Contrived example.
API.every(['one', 'two'], function(word) {
  window.alert(word);
  return false;
});

What is the expected output? What do you see instead?

Only 'one' should be displayed.
Only 'two' is displayed.

What version of the product are you using? On what operating system?

Full version from Builder @ Sat, 24 Apr 2010 02:05:12 UTC
Win2k/IE6

Please provide any additional information below.

Per ECMA-262 5th Edition, the array enumeration functions (every, some, 
filter, etc) should operate on each element of the array "in ascending 
order."  Since the native function is used when available, the replacement 
should operate the same way.

I believe only 'every' and 'some' are incorrect as the other enumeration 
functions do not need to short circuit.

Original issue reported on code.google.com by toby.oco...@gmail.com on 24 Apr 2010 at 2:23

GoogleCodeExporter commented 9 years ago
Ignore the last paragraph in the OP.  Since any enumeration function may have 
side 
effects, all enumeration functions should traverse the array in ascending 
(offset) 
order, to conform with the ECMA specification (see sections 15.4.4.16-20).

Original comment by toby.oco...@gmail.com on 29 Apr 2010 at 1:24

GoogleCodeExporter commented 9 years ago
Agreed.  I have changed forEach locally to force order and will adjust the 
others as 
well.  I wasn't originally trying to replicate the natives, but figured to 
document 
any discrepancies.  But this is easy enough to change to match.

Thanks Toby!

Original comment by dmark.ci...@gmail.com on 29 Apr 2010 at 8:26

GoogleCodeExporter commented 9 years ago

Original comment by dmark.ci...@gmail.com on 6 May 2010 at 3:14