Skip to main content

Bug Tracker

Side navigation

#9750 closed bug (duplicate)

Opened July 05, 2011 09:58PM UTC

Closed July 12, 2011 02:46PM UTC

Last modified July 12, 2011 02:46PM UTC arguments, fn ) can fail in Safari

Reported by: spicyj Owned by:
Priority: low Milestone:
Component: core Version: 1.6.2
Keywords: Cc:
Blocked by: Blocking:

The "isArray" heuristic looks at elems[ 0 ] and elems[ elems.length - 1 ]; if they are both truthy; it assumes that elems is an array. In the case that one of the two elements is falsey, map will treat it as an object instead of an array.

Normally, that's pretty much okay, but in Safari, for ( key in arguments ) seems to yield no values. This page demonstrates the bug:

By testing the two end values for undefined instead of truthiness, everything is fixed. Patch and a test on GitHub:

Attachments (0)
Change History (8)

Changed July 05, 2011 10:15PM UTC by spicyj comment:1

Changed July 05, 2011 10:44PM UTC by rwaldron comment:2

component: unfiledcore
priority: undecidedlow
resolution: → wontfix
status: newclosed

Without arguing the semantics of's first argument, you're using it like "each" which is incorrect - should not be used for side-effects. is expected to return a mutated copy of the original array or object argument. I've reduced the test case further to show the correct usage:

Changed July 05, 2011 10:48PM UTC by spicyj comment:3

My bug stands. Screenshot from your fiddle:

(In my original script, I was using properly but changed it to run console.log for that demo.)

Changed July 05, 2011 11:22PM UTC by spicyj comment:4

If you prefer to relying on's each-like functionality, you can use this patch instead which uses map "properly" in the test case:

Changed July 06, 2011 03:50AM UTC by rwaldron comment:5

resolution: wontfix
status: closedreopened

Reopening for further discussion

Changed July 11, 2011 11:12PM UTC by rkatic comment:6

This would be a duplicate of #9025 (that is wrongly declared as a duplicate) that already has a patch.

Changed July 12, 2011 02:46PM UTC by addyosmani comment:7

resolution: → duplicate
status: reopenedclosed

Changed July 12, 2011 02:46PM UTC by addyosmani comment:8

Duplicate of #9025.