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
VNodes in children become undefined after createElement() #16
Comments
This is a weird issue given the following test pass. Could you provide me a gist of your code or simplified one for testing purpose ? |
Ok, I figured out why this is happening. It's because the undefined properties have gone away at some point in the object, namely elm, key and text. After doing the below in my case, I started getting the correct outcome.
I suspect the properties are going away because I am doing some modifications before/after the |
Snabbdom-pragma main use is to move from moving to JSX pragma call to a Snabbdom Vnode, majors transformations are to handle the React.createElement api for creating a Vnode following the Snabbdom needs. Each Vnode we work with are trusted Snabbdom Vnode, so I never figured out of outly manipuled Vnodes. |
Because Snabbdom does not deal with component lifecycles in a more react-like manner, I decided to do some sort of "pre-processing" to custom components. The only thing that remains in my code is the |
Snabbdom-pragma aim to be compiler/transpiler and framework independent focusing only on Im glad you found a solution on your own. |
So I figured out exactly the reason for why after a
For me personally, this could be a reason for covering these missing properties in |
So : Not defined Vnode properties need to be handle or set as undefined. |
This is a 1:1 copy of my wrapper function, where I recurse into the children and set them to
|
I am pretty busy, I will work on it as soon as possible. |
@wbern Can you provide the exact code that is mutating the vnode (removing the undefined keys)? I tried the following but is keeping the properties: var x = [{key: undefined}]
var y = x.map(val => val) // [{key: undefined}] I have some ideas how to fix it but need a reproduction example to create a test |
@blikblum Sorry I have moved on to another project and don't have access to the material anymore. |
I have this virtual node (called
children
), previously created usingcreateElement()
I want to pass this into a new
createElement()
-call like below:Snabbdom.createElement('div', undefined, children);
But the result then becomes:
If I however do
Snabbdom.createElement('div', undefined, h('div', undefined, children));
, I get the correct output (but with an additional unwanted element inbetween):Is there a better work-around to re-use vnodes? Would it be possible to allow vnodes to be passed into children, like what
h()
-calls currently allow?The text was updated successfully, but these errors were encountered: