Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prototype object of ES6 classes always non-writable #2025

Closed
broadsw0rd opened this issue Jul 17, 2015 · 4 comments · Fixed by #12115
Closed

Prototype object of ES6 classes always non-writable #2025

broadsw0rd opened this issue Jul 17, 2015 · 4 comments · Fixed by #12115
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Spec Compliance 👓 A type of pull request used for our changelog categories

Comments

@broadsw0rd
Copy link

If we try to compile this snippet with babel, we will get true in our console. But if run it in Chrome 43, we will get false.

class Foo{}

console.log(Object.getOwnPropertyDescriptor(Foo, 'prototype').writable)
@broadsw0rd broadsw0rd changed the title Prorotype object of ES6 classes are always non-writable Prorotype object of ES6 classes always non-writable Jul 17, 2015
@sebmck
Copy link
Contributor

sebmck commented Jul 17, 2015

Reference:

14.5.14 Runtime Semantics: ClassDefinitionEvaluation

  1. Perform MakeConstructor(F, false, proto).

Second argument to MakeConstructor is writablePrototype.

@sebmck
Copy link
Contributor

sebmck commented Jul 17, 2015

I can do this for derived classes since they already use a helper and it wouldn't be much extra but I'm not sure if it's worth it for plain classes.

@sebmck sebmck added the PR: Spec Compliance 👓 A type of pull request used for our changelog categories label Jul 17, 2015
@broadsw0rd
Copy link
Author

I'm sure this is totally not necessary for loose mode in both cases

@jamiebuilds jamiebuilds changed the title Prorotype object of ES6 classes always non-writable Prototype object of ES6 classes always non-writable Jul 26, 2015
wentout added a commit to wentout/babel that referenced this issue Sep 28, 2020
wentout added a commit to wentout/babel that referenced this issue Sep 28, 2020
@wentout
Copy link
Contributor

wentout commented Sep 28, 2020

Started an attempt to fix here: #12115

nicolo-ribaudo added a commit to wentout/babel that referenced this issue Dec 10, 2021
nicolo-ribaudo pushed a commit to wentout/babel that referenced this issue Dec 10, 2021
nicolo-ribaudo added a commit that referenced this issue Dec 10, 2021
* initial code 2 fix the issue #2025

* Mark class prototype as read-only

* Update fixtures

* Fix failure

* Update Babel 8 fixtures

* Disable in loose mode

* Update fixtures

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
justingrant added a commit to justingrant/proposal-temporal that referenced this issue Dec 13, 2021
This PR fixes tc39#1965:
1. For Intl.DateTimeFormat, sets `writeable: false` on  `prototype`
   because it's created using `function` (which has a writeable
   `prototype`, unlike `class` which is not writeable).
2. For Temporal classes, there's a Babel bug that causes prototypes to
   be writeable (babel/babel#2025) and this PR
   works around it.
justingrant added a commit to justingrant/proposal-temporal that referenced this issue Dec 14, 2021
This PR fixes tc39#1965:
1. For Intl.DateTimeFormat, sets `writeable: false` on  `prototype`
   because it's created using `function` (which has a writeable
   `prototype`, unlike `class` which is not writeable).
2. For Temporal classes, there's a Babel bug that causes prototypes to
   be writeable (babel/babel#2025) and this PR
   works around it.
justingrant added a commit to tc39/proposal-temporal that referenced this issue Dec 14, 2021
This PR fixes #1965:
1. For Intl.DateTimeFormat, sets `writeable: false` on  `prototype`
   because it's created using `function` (which has a writeable
   `prototype`, unlike `class` which is not writeable).
2. For Temporal classes, there's a Babel bug that causes prototypes to
   be writeable (babel/babel#2025) and this PR
   works around it.
@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 12, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue PR: Spec Compliance 👓 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants