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

fix: unsupported function defined inside a condition block. #7263 #7411

Merged
merged 2 commits into from
May 29, 2018

Conversation

aleen42
Copy link
Contributor

@aleen42 aleen42 commented May 28, 2018

Issue Reference

fixes #7263

What kind of change does this PR introduce?

Call the method onScriptComplete after its declaration as there should ben an error of references under Friefox 40, when it has been declared inside a conditon block, rather than the top block inside a function.

Did you add tests for your changes?

No needs.

Does this PR introduce a breaking change?

Solve the problem under Firefox 40.

What needs to be documented once your changes are merged?

No needs.

@jsf-clabot
Copy link

jsf-clabot commented May 28, 2018

CLA assistant check
All committers have signed the CLA.

@webpack-bot
Copy link
Contributor

webpack-bot commented May 28, 2018

For maintainers only:

  • This need to be documented (issue in webpack/webpack.js.org will be filed when merged)

@aleen42
Copy link
Contributor Author

aleen42 commented May 28, 2018

A separate PR for fixing remaining problems of #7210.

@ooflorent
Copy link
Member

function declarations are hoisted. This should not be an issue.

Copy link
Member

@ooflorent ooflorent left a comment

Choose a reason for hiding this comment

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

LGTM. However, please fix styling issues.

@aleen42
Copy link
Contributor Author

aleen42 commented May 28, 2018

@ooflorent hoisted function does not work inside condition block under FireFox.

@aleen42
Copy link
Contributor Author

aleen42 commented May 28, 2018

@ooflorent It seems like my fault, and the result should not be an issue, as it has been executed within another event loop:

image

image

@sokra
Copy link
Member

sokra commented May 28, 2018

So we can close it?

@aleen42
Copy link
Contributor Author

aleen42 commented May 29, 2018

It depends on you all. In my opinion, it is still not proper to declare function inside a condition block, a.k.a inner-declaration, according to a document of ESLint, and I will submit another commit for this, and revert the commit of #7210.

@webpack-bot
Copy link
Contributor

@aleen42 Thanks for your update.

I labeled the Pull Request so reviewers will review it again.

@sokra Please review the new changes.

@aleen42
Copy link
Contributor Author

aleen42 commented May 29, 2018

Hoisted variables should be avoided, like using let or const within ES6, rather than var.

@aleen42
Copy link
Contributor Author

aleen42 commented May 29, 2018

@sokra It seems that the "stats test cases" has not already been matched?

Use a varaible declaration outside a condition block instead, according to https://eslint.org/docs/rules/no-inner-declarations
@aleen42 aleen42 force-pushed the master branch 2 times, most recently from ff1a929 to 9c3d7a2 Compare May 29, 2018 06:33
@webpack-bot
Copy link
Contributor

Thank you for your pull request! The most important CI builds succeeded, we’ll review the pull request soon.

]),
`}, ${chunkLoadTimeout});`,
"function onScriptComplete(event) {",
"onScriptComplete = function (event) {",
Copy link
Member

Choose a reason for hiding this comment

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

function onScriptComplete(event) { was fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As an inner declaration, it was not fine to some extends.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@webpack-bot
Copy link
Contributor

Hi @aleen42.

Just a little hint from a friendly bot about the best practice when submitting pull requests:

Don't submit pull request from your own master branch. It's recommended to create a feature branch for the PR.

You don't have to change it for this PR, just make sure to follow this hint the next time you submit a PR.

Copy link
Member

@sokra sokra left a comment

Choose a reason for hiding this comment

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

Ok let's use that

@sokra
Copy link
Member

sokra commented May 29, 2018

@aleen42 please also sign the CLA

@aleen42
Copy link
Contributor Author

aleen42 commented May 29, 2018

I have signed it and can u check this? @sokra

@sokra sokra closed this May 29, 2018
@sokra sokra reopened this May 29, 2018
@sokra sokra merged commit 1e09650 into webpack:master May 29, 2018
@sokra
Copy link
Member

sokra commented May 29, 2018

Thanks

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

Successfully merging this pull request may close these issues.

onScriptComplete is not defined under Firefox 40
5 participants