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: Preserve complex props across connectedCallback calls #71

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

xPapay
Copy link

@xPapay xPapay commented Apr 11, 2022

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:

{ ...this._props, context },

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:

a = element.attributes,

Fixes #69

This fixes the issue when the complex prop was not preserved
across connectectedCallback calls.

When complex prop is set as first property then everything
worked as expected. But when complex prop is set after other prop
then it was not stored into this._props and that caused missing it
in the implicit connectedCallback call. Because in connectedCallback
we set props from attributes (simple props) and from this._props.
@trygveaa
Copy link

trygveaa commented Jul 3, 2024

Any chance to get this merged? It's very impractical to not be able to use complex properties normally.

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.

It resets complex property to undefined when provided as second or later prop
2 participants