You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(compiler): account for an existing constructor in convert-decorators (#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.
0 commit comments