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

Update this reference to self #3137

Closed
wants to merge 1 commit into from
Closed

Update this reference to self #3137

wants to merge 1 commit into from

Conversation

Itee
Copy link

@Itee Itee commented Sep 17, 2018

Hi there,

In this._execCommand at line 73 the this keyword is use instead of self. In case of _execCommand override or external call, this will be undefined.

This proposal just fix that.

Check that your description matches the automatic change-log format:
http://karma-runner.github.io/2.0/dev/git-commit-msg.html
then delete this reminder.

Hi there,

In `this._execCommand` at line 73 the `this` keyword is use instead of `self`. In case of _execCommand override or external call, `this` will be undefined.

This proposal just fix that.
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here (e.g. I signed it!) and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

@Itee
Copy link
Author

Itee commented Sep 17, 2018

I signed it!

@googlebot
Copy link

CLAs look good, thanks!

lusarz
lusarz previously approved these changes Oct 1, 2018
@lusarz
Copy link
Contributor

lusarz commented Oct 1, 2018

@Itee thanks for pull request. Would you mind to update commit message ? Karma use validate-commit-msg style for that. My proposition is:

fix(launcher): update this reference to self

@@ -70,7 +70,7 @@ function ProcessLauncher (spawn, tempDir, timer, processKillTimeout) {
return self._clearTempDirAndReportDone('no binary')
}

cmd = this._normalizeCommand(cmd)
cmd = self._normalizeCommand(cmd)
Copy link
Contributor

Choose a reason for hiding this comment

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

@devoto13, @johnjbarton
What do you thinks about that ? I did something opposite here:
#3157

Copy link
Collaborator

@devoto13 devoto13 Oct 3, 2018

Choose a reason for hiding this comment

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

Consider this example: https://jsfiddle.net/devoto13/1ptvhgxn/

Apparently the only case, where it has incorrect this is when method is passed as callback by reference (i.e. .then(myClass.myMethod)) or similar, which is ultimately shooting yourself in the foot. So I think your (@lusarz's) way is good as long as we (and consumers) avoid this pattern.

But maybe I'm missing something. @Itee can you provide a more complete example of when this breaks?

Copy link
Collaborator

Choose a reason for hiding this comment

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

But note that changes from self to this can potentially be breaking to the third-party code, which uses the mentioned pattern, so should probably go into a major version.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks @devoto13 for great input - I'll analyze your example more precisely tomorrow, but I think I know what you mean.

That's true - it would be better to release major version with these changes

@lusarz lusarz dismissed their stale review October 3, 2018 18:29

Need more investigation

@johnjbarton
Copy link
Contributor

Sorry this did not work out. I'm going to close a lot of older pull requests as the source code has changed a lot over the last year.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants