diff.js
function destroyWidgets(vNode, patch, index) {
    if (isWidget(vNode)) {
        if (typeof vNode.destroy === "function") {
            patch[index] = new VPatch(VPatch.REMOVE, vNode, null)
        }
    } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
        var children = vNode.children
        var len = children.length
        for (var i = 0; i < len; i++) {
            var child = children[i]
            index += 1

            destroyWidgets(child, patch, index)

            if (isVNode(child) && child.count) {
                index += child.count
            }
        }
    } else if (isThunk(vNode)) {
        thunks(vNode, null, patch, index)
    }
}
function destroyWidgets(vNode, patch, index) {
    if (isWidget(vNode)) {
        if (typeof vNode.destroy === "function") {
            patch[index] = new VPatch(VPatch.REMOVE, vNode, null)
        }
    } else if (isVNode(vNode) && (vNode.hasWidgets || vNode.hasThunks)) {
        var children = vNode.children
        var len = children.length
        for (var i = 0; i < len; i++) {
            var child = children[i]
            index += 1

            destroyWidgets(child, patch, index)

            if (isVNode(child) && child.count) {
                index += child.count
            }
        }
    } else if (isThunk(vNode)) {
        thunks(vNode, null, patch, index)
    }
}
function destroyWidgets ( vNode , patch , index ) { if ( isWidget ( vNode ) ) { if ( typeof vNode . destroy === "function" ) { patch [ index ] = new VPatch ( VPatch . REMOVE , vNode , null ) } } else if ( isVNode ( vNode ) && ( vNode . hasWidgets || vNode . hasThunks ) ) { var children = vNode . children var len = children . length for ( var i = 0 ; i < len ; i ++ ) { var child = children [ i ] index += 1 destroyWidgets ( child , patch , index ) if ( isVNode ( child ) && child . count ) { index += child . count } } } else if ( isThunk ( vNode ) ) { thunks ( vNode , null , patch , index ) } }
Patch records for all destroyed widgets must be added because we need a DOM node reference for the destroy function
Patch records for all destroyed widgets must be added because we need a DOM node reference for the destroy function