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

Receive old props and content in component patch method #2

Closed
andriichumak opened this issue Oct 12, 2017 · 3 comments
Closed

Receive old props and content in component patch method #2

andriichumak opened this issue Oct 12, 2017 · 3 comments

Comments

@andriichumak
Copy link
Contributor

It seems that the only way to keep track of changes to props in component (e.i. why patch was called) is to put old data on DOM object custom property, which seems wrong.

Would it makes sense to pass old props / content to patch method of custom component? Something like componentInstance.patch(domNode, newProps, newContent, oldProps, oldContent). This way developer could figure out what exactly has changed and apply targeted patch on DOM.

I realize this leads to a wider topic of component internal state, which defeats the purpose of micro library. You probably want to keep it simple. On the other hand old props and content are available when patch is called anyway, so why not?

I could make a PR if you think this is a good idea.

@yelouafi
Copy link
Owner

seems a good idea! thanks

@yelouafi
Copy link
Owner

BTW what do you think about the signature

componentInstance.patch(domNode, newProps, oldProps, newContent, oldContent)

In the case where the component has no content this could simplify the signature to

componentInstance.patch(domNode, newProps, oldProps)

@andriichumak
Copy link
Contributor Author

andriichumak commented Oct 16, 2017

That's a good idea. The only disadvantage is that it's a breaking change from current API. So, you might have to bump major/minor version after this change.

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

No branches or pull requests

2 participants