Fix: Preserve complex props across connectedCallback calls #71
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes the issue, when complex prop is lost on repeated connectedCallback call.
It fixes it by saving all props into this._props.
The issue was that when complex prop was set as second or later prop (after vdom was created) we did not store it into
this._props
field.Then it is missing when connectedCallback is called implicitly (when element inserted into DOM),
because we use there this._pros when rendering vdom; see:
preact-custom-element/src/index.js
Line 81 in 5790765
The simple props were not affected even if we set them as second or later prop because those are preserved in the attributes, and provided into vdom in connectedCallback, see:
preact-custom-element/src/index.js
Line 140 in 5790765
Fixes #69