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

Make special case for class property initializers in shadow-functions #4502

Merged
merged 1 commit into from Oct 14, 2016

Conversation

motiz88
Copy link
Contributor

@motiz88 motiz88 commented Sep 11, 2016

Q A
Bug fix? yes
Breaking change? no
New feature? no
Deprecations? no
Spec compliancy? yes
Tests added/pass? yes
Fixed tickets #4337 (partially), #4230 (needs verification)
License MIT

This modifies shadow-functions to leave references to this and arguments unmodified in the context of a class property's value expression. The effect is akin to introducing an implicit scope around each such initializer, and is in line with the current proposal AFAICT.

All this applies only when emitting code with the class properties syntax and not running it through transform-class-properties - which is the only way such syntax can reach shadow-functions. The transform itself is correct and unchanged.

@codecov-io
Copy link

codecov-io commented Sep 11, 2016

Current coverage is 88.74% (diff: 100%)

Merging #4502 into master will increase coverage by <.01%

@@             master      #4502   diff @@
==========================================
  Files           195        195          
  Lines         13773      13776     +3   
  Methods        1425       1425          
  Messages          0          0          
  Branches       3171       3173     +2   
==========================================
+ Hits          12223      12226     +3   
  Misses         1550       1550          
  Partials          0          0          

Powered by Codecov. Last update 0e02a18...545b966

if (path.parentPath && path.parentPath.isClassProperty() && path.key === "value") {
return true;
}
if (first) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than using this flag, which took me a minute to process, could we perhaps do

let fnPath = path.find(function (innerPath) { // rename argument
    if (innerPath.parentPath && innerPath.parentPath.isClassProperty() && innerPath.key === "value") {
        return true;
    }
    if (path === innerPath) return false;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@motiz88 motiz88 force-pushed the class-property-initializer-blocks-shadow branch from b2a61fb to 545b966 Compare October 1, 2016 12:44
@hzoo hzoo added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Oct 14, 2016
@hzoo hzoo merged commit 2827d66 into babel:master Oct 14, 2016
chrisprice pushed a commit to chrisprice/babel that referenced this pull request Oct 18, 2016
panagosg7 pushed a commit to panagosg7/babel that referenced this pull request Jan 17, 2017
@motiz88 motiz88 deleted the class-property-initializer-blocks-shadow branch April 2, 2017 07:53
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 6, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 6, 2019
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: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants