moy-dom
Version:
A flexiable Virtual DOM library for building modern web interface.
20 lines • 671 B
JavaScript
import applyPatches from './applyPatches'
/**
* [dfsWalk apply patches for given node(recursion)]
* @param {[DOMElements]} node [the node]
* @param {[Object]} walker [the current node index, Object for deep compare changed the index]
* @param {[patches]} patches [the patches]
* @return {[undefined]} [undefined]
*/
export default function dfsWalk(node, walker, patches){
const currentPatches = patches[walker.index]
const len = node.childNodes.length
for(let i = 0; i < len; i ++){
let child = node.childNodes[i]
walker.index ++
dfsWalk(child, walker, patches)
}
if(currentPatches){
applyPatches(node, currentPatches)
}
}