import '../types';
import {NodeTreeRenderer} from "./nodetree";

export const Host = Symbol('Host');

/**
 * Takes care of rendering a Host-node
 *
 * @class
 * @implements {VNodeRenderer}
 */
export const HostNodeRenderer = {
    /**
     * @param {VRenderItem} item
     */
    create(item){
        if(!item.parent) throw new Error("Host node cannot appear as a top-level element unless a parent is provided");
        else return item.parent;
    },
    
    /**
     * @param {VRenderItem} item
     */
    remove(item){
       // NO-OP
    },
    
    /**
     *
     * @param {VRenderItem} item
     * @param {VRenderState} state
     */
    update(item, state){
        item.host = item.host || item.parent;
        NodeTreeRenderer.update(item,state);
    },
};