-
Notifications
You must be signed in to change notification settings - Fork 790
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): account for an existing constructor in convert-decorat…
…ors (#3776) This change ensures that statements in an existing constructor are not thrown on the floor in the case that we need to edit a constructor (i.e. when there is a field with `@Prop` that we need to initialize in the constructor). In f977830 we made a change to initialize any class fields decorated with `@Prop()` in a constructor. The code to do this would look for a constructor on the class and, if found, update the body of the constructor with statements to initialize the field. Unfortunately, that commit would drop all existing statements in the constructor on the floor! This broke how some Stencil users initialize fields or do certain side effects, since no code they wrote in their constructors would make it through to the built output. This commit fixes the issue by instead setting the constructor body to be all of our newly created statements followed by any existing statements. This will allow users to initialize fields to custom values in the constructor if they so chose. See #3773 for an issue describing the issue.
- Loading branch information
1 parent
8c1c35c
commit 7c92dbf
Showing
2 changed files
with
130 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters