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

Unmanaged VNodes (external dom-manipulation) #271

Open
cornerman opened this issue Dec 10, 2018 · 2 comments
Open

Unmanaged VNodes (external dom-manipulation) #271

cornerman opened this issue Dec 10, 2018 · 2 comments

Comments

@cornerman
Copy link
Member

cornerman commented Dec 10, 2018

In general working with third-party libs works quite good with Outwatch. You can use onDom* Hooks or managedElement(elem => Cancelable(() => ...)) and integrate with other libraries using the dom element. But there is a problem when these libraries do a lot of dom-manipulation themselves.

Example: When using ui frameworks like semantic-ui, you might end up with VNodes that are moved inside the dom by semantic-ui. So Outwatch cannot see those changes and the virtual dom will get out of sync with the actual dom. Succeeding patch calls with snabbdom will therefore most likely fail.

We can workaround some of the issues when wrapping such nodes with div.static(key)(<unmanaged vnode>). But this will still lead to errors when you want to remove this vnode again.

For proper handling, we could introduce an unmanaged vnode type. We just do the initial rendering of such VNodes and any updates coming from its observables. But like a thunk/static we would never rerender the node if it is already there and additionally will never remove the node. We would just call onDestroy and the user would need to handle that himself. For example, in semantic-ui, we could just destroy the element with jquery. We could even destroy it in Outwatch if an id is provided.

Any additional requirements or ideas?

@fdietze
Copy link
Member

fdietze commented Jan 5, 2019

This could help: https://github.com/snabbdom/snabbdom/blob/master/README.md#snabbdomtovnode

Flag a dom node as dirty, to tell outwatch to re-read the dom into a vnode.

@cornerman
Copy link
Member Author

We will also want an outwatch-react and/or outwatch-vue module that provides helpers to use these kind of unmanaged nodes to render react/vue components inside of outwatch.

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

No branches or pull requests

2 participants