Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Should set .elm property on created vnodes #13

Closed
stucox opened this issue Jul 20, 2016 · 2 comments
Closed

Should set .elm property on created vnodes #13

stucox opened this issue Jul 20, 2016 · 2 comments

Comments

@stucox
Copy link

stucox commented Jul 20, 2016

I wonder if virtualize() should set the .elm property on the nodes it creates, such that:

var div = document.createElement('div');
var vnode = virtualize(div);
console.log(vnode.elm == div)  // true

Reasoning:

My use case for snabbdom-virtualize is to “pick up where I left off” with a server-rendered DOM: snabbdom’s patch(oldVnode, newVnode) function expects both oldVnode and newVnode to be virtual, so I was hoping to virtualize the existing DOM before patch()ing with the next state.

However, snabbdom needs the .elm reference to tie elements up properly, which snabbdom-virtualize doesn’t set.

Is there any reason why setting .elm to refer to the source node would be a bad idea?

@stucox
Copy link
Author

stucox commented Jul 20, 2016

Alternatively if hooks.create() callback passed the source node, users of this lib would be able to add this functionality themselves.

@rayd
Copy link
Member

rayd commented Aug 29, 2016

This should be resolved in 0.6.0 thanks to @katyo's #14

@rayd rayd closed this as completed Aug 29, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants