Matt-Esch/virtual-dom

Patch does nothing

are opened this issue · 6 comments

are commented

I have no idea what I'm doing wrong, but it seems like patch is doing completely nothing (even with populated patches). How is this possible? No error thrown, just silently does nothing.

    let _rootElement = document.querySelector(el.value)
    
    let rootTree = h('div')
    let rootNode = createElement(rootTree)

    _rootElement.appendChild(rootNode)
    
    let updateFn = () => {
      let vElement = c.execute().value // this returns new VNode
      
      let patches = diff(rootTree, vElement) // this returns an object with few patches
      rootNode = patch(rootNode, patches) // THIS does nothing

      rootTree = vElement
    }
are commented

I think this happens, when VNode returned by the c.execute().value has children added after using h. May it be the reason?

Did you ever figure this out? I'm experiencing something similar.

are commented

I think you cannot manipulate the vnodes after creating them, so check if you don't append children somewhere in your code.

You're absolutely right. There was a place in my code where I was making VNodes then appending new children to them.

@gryphonmyers Close the issue.

Would if I could!