"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const namespaceURI_1 = require("../../../../../client/component/namespaceURI");
const element_1 = require("../../../../../client/element");
const style_1 = require("../../../../../client/style");
class SVGUse extends element_1.Element {
    constructor($props, $system) {
        super($props, $system);
        const { className, style = {}, href } = this.$props;
        const use_el = this.$system.api.document.createElementNS(namespaceURI_1.namespaceURI, 'use');
        if (className !== undefined) {
            use_el.classList.value = className;
        }
        if (href !== undefined) {
            use_el.setAttributeNS(namespaceURI_1.namespaceURI, 'xlink:href', href);
            use_el.setAttribute('href', href);
        }
        (0, style_1.applyStyle)(use_el, style);
        this._use_el = use_el;
        this.$element = use_el;
    }
    onPropChanged(prop, current) {
        if (prop === 'style') {
            (0, style_1.applyStyle)(this._use_el, current);
        }
        else if (prop === 'href') {
            if (current) {
                this._use_el.setAttributeNS(namespaceURI_1.namespaceURI, 'xlink:href', current);
                this._use_el.setAttribute('href', current);
            }
            else {
                this._use_el.removeAttributeNS(namespaceURI_1.namespaceURI, 'xlink:href');
                this._use_el.removeAttribute('href');
            }
        }
    }
}
exports.default = SVGUse;
//# sourceMappingURL=Component.js.map