define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    /**
     * Sets the virtual parent of an element.
     * Pass `undefined` as the `parent` to clear the virtual parent.
     *
     * @public
     */
    function setVirtualParent(child, parent) {
        var virtualChild = child;
        var virtualParent = parent;
        if (!virtualChild._virtual) {
            virtualChild._virtual = {
                children: []
            };
        }
        var oldParent = virtualChild._virtual.parent;
        if (oldParent && oldParent !== parent) {
            // Remove the child from its old parent.
            var index = oldParent._virtual.children.indexOf(virtualChild);
            if (index > -1) {
                oldParent._virtual.children.splice(index, 1);
            }
        }
        virtualChild._virtual.parent = virtualParent || undefined;
        if (virtualParent) {
            if (!virtualParent._virtual) {
                virtualParent._virtual = {
                    children: []
                };
            }
            virtualParent._virtual.children.push(virtualChild);
        }
    }
    exports.setVirtualParent = setVirtualParent;
});
//# sourceMappingURL=setVirtualParent.js.map