Bug 145460 - Make Function.(name|length) configurable
Summary: Make Function.(name|length) configurable
Status: RESOLVED WORKSFORME
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
: 158062 (view as bug list)
Depends on:
Blocks:
 
Reported: 2015-05-29 10:17 PDT by Yury Selivanov
Modified: 2016-05-25 10:51 PDT (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Yury Selivanov 2015-05-29 10:17:12 PDT
This is an important feature for OOP libraries: typically classes are emulated using functions, hence class *static* properties are properties of the function object that represents the class.  Since '.name' and '.length' properties are read-only and non-configurable for functions, there is no way to have '.name' and '.length' static properties for classes.

This is something that has already been fixed in Chrome and Firefox:

- https://bugzilla.mozilla.org/show_bug.cgi?id=1084019
- https://chromium.googlesource.com/v8/v8/+/f6cd009efd7a032907b11265e74102b0d45207a1%5E!/

And InternetExplorer doesn't have any restrictions on these properties, which leaves WebKit/Safari the only browser that doesn't support this.
Comment 1 Yury Selivanov 2015-05-29 10:23:59 PDT
In short, the following should work:

function f(){};
Object.defineProperty(f, 'name', {value: 'g'});
Comment 2 Simon Pieters (:zcorpan) 2016-05-25 03:08:19 PDT
*** Bug 158062 has been marked as a duplicate of this bug. ***
Comment 4 Mark Lam 2016-05-25 10:51:57 PDT
This is already fixed in ToT.  You can verify this for yourself using Safari Technology Preview or a WebKit Nightly build (https://webkit.org/downloads/).