RESOLVED FIXED 145202
ES6: Implement Object.setPrototypeOf
https://bugs.webkit.org/show_bug.cgi?id=145202
Summary ES6: Implement Object.setPrototypeOf
Joseph Pecoraro
Reported 2015-05-19 21:39:07 PDT
* SUMMARY Add support for Object.setPrototypeOf. This is already very similar to __proto__ assignment, which we already support, with a few minor differences (throwing exceptions in some cases, and return values). * REFERENCE <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf> * SPEC ES6 19.1.2.18 <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.setprototypeof> > When the setPrototypeOf function is called with arguments O and proto, the following steps are taken: > > 1. Let O be RequireObjectCoercible(O). > 2. ReturnIfAbrupt(O). > 3. If Type(proto) is neither Object nor Null, throw a TypeError exception. > 4. If Type(O) is not Object, return O. > 5. Let status be O.[[SetPrototypeOf]](proto). > 6. ReturnIfAbrupt(status). > 7. If status is false, throw a TypeError exception. > 8. Return O. Compare this to Object.prototype.__proto__: <https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set-object.prototype.__proto__> * TEST js> o = {}; Object.setPrototypeOf(o, Array.prototype); o instanceof Array; => should be true * NOTES - This is covered by the ES6 Compat Table: <https://kangax.github.io/compat-table/es6/#Object_static_methods_Object.setPrototypeOf> - Other browsers have implemented this: (their tests cases are nearly identical) - Chrome (v8): <https://code.google.com/p/v8/source/detail?r=18739> - Firefox: <https://bugzilla.mozilla.org/show_bug.cgi?id=885788>
Attachments
[PATCH] Proposed Fix (52.38 KB, patch)
2015-05-19 21:43 PDT, Joseph Pecoraro
no flags
Radar WebKit Bug Importer
Comment 1 2015-05-19 21:39:27 PDT
Joseph Pecoraro
Comment 2 2015-05-19 21:43:53 PDT
Created attachment 253425 [details] [PATCH] Proposed Fix
WebKit Commit Bot
Comment 3 2015-05-20 10:23:13 PDT
Comment on attachment 253425 [details] [PATCH] Proposed Fix Clearing flags on attachment: 253425 Committed r184642: <http://trac.webkit.org/changeset/184642>
WebKit Commit Bot
Comment 4 2015-05-20 10:23:17 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.