Bug 138563 - The third parameter of a Map.prototype.forEach callback function is undefined
Summary: The third parameter of a Map.prototype.forEach callback function is undefined
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Matthew Mirman
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2014-11-10 05:09 PST by Steve South
Modified: 2015-06-09 13:31 PDT (History)
4 users (show)

See Also:


Attachments
Patch (6.55 KB, patch)
2014-12-07 07:23 PST, Diego Pino
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Steve South 2014-11-10 05:09:12 PST
Codepen here:

http://codepen.io/stevesouth/pen/NPKzYz/

According to MDN the callback function of a Map.forEach should get called with three arguments

callback is invoked with three arguments:

    the element value
    the element key
    the Map object being traversed

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map/forEach

However in Webkit the third parameter is undefined.
Comment 1 Radar WebKit Bug Importer 2014-11-11 11:52:34 PST
<rdar://problem/18943661>
Comment 2 Diego Pino 2014-12-07 07:23:15 PST
Created attachment 242741 [details]
Patch
Comment 3 Diego Pino 2014-12-07 07:26:01 PST
The same change is necessary for Set. According to the ES6 spec [1]:

"callbackfn is called with three arguments: the first two arguments are a value contained in the Set. The same value of passed for both arguments. The Set object being traversed is passed as the third argument."

[1] http://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.foreach
Comment 4 Matthew Mirman 2015-06-09 12:56:08 PDT
Comment on attachment 242741 [details]
Patch

The map part was updated in http://trac.webkit.org/changeset/183374
Comment 5 Matthew Mirman 2015-06-09 12:57:49 PDT
And the set part in https://bugs.webkit.org/show_bug.cgi?id=144188
Comment 6 Geoffrey Garen 2015-06-09 13:05:31 PDT
Comment on attachment 242741 [details]
Patch

r=me