Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Mithril v/dom alignment
export default function * vTreeWalker(vnode){
yield vnode
if(vnode.instance)
yield * vTreeWalker(vnode.instance)
else if(Array.isArray(vnode.children))
for(const child in vnode.children)
yield * vTreeWalker(child)
}
Owner

barneycarroll commented Feb 17, 2017

TODO:

  • Patch upstream to nearest dom.vnode for m.render integration (consider fragments - is it possible?)

API:

function malign(dom, vnode, {cycle = 0, post = false, push = true}){
  // dom is the live DOM tree, vnode is the vDOM tree to align to it
  // cycle 0 means run no lifecycle methods - treat vnode tree as static
  // cycle 1 means run oninit and view
  // cycle 2 means run onbeforeupdate and view
  // post means run oncreate if cycle is 1, onupdate if cycle is 2
  // push means to find the upstream mountpoint and merge the aligned vnode into its records

  // returns the mutated vnode
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment