|
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- const CSSStyleDeclaration_1 = __importDefault(require("../../css/declaration/CSSStyleDeclaration"));
- const Element_1 = __importDefault(require("../element/Element"));
- /**
- * SVG Element.
- *
- * Reference:
- * https://developer.mozilla.org/en-US/docs/Web/API/SVGElement.
- */
- class SVGElement extends Element_1.default {
- constructor() {
- super(...arguments);
- // Events
- this.onabort = null;
- this.onerror = null;
- this.onload = null;
- this.onresize = null;
- this.onscroll = null;
- this.onunload = null;
- this._style = null;
- }
- /**
- * Returns viewport.
- *
- * @returns SVG rect.
- */
- get viewportElement() {
- return null;
- }
- /**
- * Returns current translate.
- *
- * @returns Element.
- */
- get ownerSVGElement() {
- const parent = this.parentNode;
- while (parent) {
- if (parent['tagName'] === 'SVG') {
- return parent;
- }
- }
- return null;
- }
- /**
- * Returns data set.
- *
- * @returns Data set.
- */
- get dataset() {
- const dataset = {};
- for (const name of Object.keys(this._attributes)) {
- if (name.startsWith('data-')) {
- dataset[name.replace('data-', '')] = this._attributes[name].value;
- }
- }
- return dataset;
- }
- /**
- * Returns style.
- *
- * @returns Style.
- */
- get style() {
- if (!this._style) {
- this._style = new CSSStyleDeclaration_1.default(this);
- }
- return this._style;
- }
- /**
- * @override
- */
- setAttributeNode(attribute) {
- const replacedAttribute = super.setAttributeNode(attribute);
- if (attribute.name === 'style' && this._style) {
- this._style.cssText = attribute.value;
- }
- return replacedAttribute;
- }
- /**
- * @override
- */
- removeAttributeNode(attribute) {
- super.removeAttributeNode(attribute);
- if (attribute.name === 'style' && this._style) {
- this._style.cssText = '';
- }
- return attribute;
- }
- }
- exports.default = SVGElement;
- //# sourceMappingURL=SVGElement.js.map
|