"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var VirtualDoc = (function () {
    function VirtualDoc(win) {
        this.defaultView = win;
        this.parentWindow = win;
    }
    VirtualDoc.prototype.createElementNS = function (namespace, name) {
        return new VirtualNode(name, {}, [], this);
    };
    VirtualDoc.prototype.createElement = function (name) {
        return new VirtualNode(name, {}, [], this);
    };
    VirtualDoc.prototype.createTextNode = function (text) {
        return text + '';
    };
    return VirtualDoc;
}());
exports.VirtualDoc = VirtualDoc;
var VirtualStyle = (function () {
    function VirtualStyle(hostNode, properties) {
        this.hostNode = hostNode;
        this.properties = properties || {};
    }
    VirtualStyle.prototype.removeProperty = function (name) {
        delete this.properties[name];
    };
    return VirtualStyle;
}());
exports.VirtualStyle = VirtualStyle;
var VirtualNode = (function () {
    function VirtualNode(elementName, attributes, children, ownerDocument) {
        this.elementName = elementName;
        this.attributes = attributes || {};
        if (!this.attributes.style) {
            this.attributes.style = {};
        }
        this.attributes.style = new VirtualStyle(this, this.attributes.style);
        this.children = children || [];
        this.ownerDocument = ownerDocument;
        this.listeners = {};
    }
    Object.defineProperty(VirtualNode.prototype, "style", {
        get: function () {
            return this.attributes.style;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(VirtualNode.prototype, "childNodes", {
        get: function () {
            return this.children;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(VirtualNode.prototype, "tagName", {
        get: function () {
            return this.elementName.toUpperCase();
        },
        enumerable: true,
        configurable: true
    });
    VirtualNode.prototype.appendChild = function (child) {
        this.children.push(child);
    };
    VirtualNode.prototype.replaceChild = function (incoming, existing) {
        for (var i = this.children.length - 1; i >= 0; i--) {
            if (this.children[i] === existing) {
                this.children.splice(i, 1, incoming);
            }
        }
    };
    VirtualNode.prototype.removeChild = function (existing) {
        for (var i = this.children.length - 1; i >= 0; i--) {
            if (this.children[i] === existing) {
                this.children.splice(i, 1);
            }
        }
    };
    VirtualNode.prototype.removeAttribute = function (name) {
        delete this.attributes[name];
    };
    VirtualNode.prototype.setAttribute = function (name, value) {
        this.attributes[name] = value;
    };
    VirtualNode.prototype.getAttribute = function (name) {
        return this.attributes[name];
    };
    VirtualNode.prototype.addEventListener = function (name, fn) {
        if (!this.listeners[name]) {
            this.listeners[name] = [];
        }
        this.listeners[name].push(fn);
    };
    VirtualNode.prototype.getBoundingClientRect = function () {
        return {
            top: 1,
            right: 1,
            bottom: 1,
            left: 1,
            width: 1,
            height: 1,
        };
    };
    return VirtualNode;
}());
exports.default = VirtualNode;
//# sourceMappingURL=VirtualNode.js.map