版博士V2.0程序
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

95 rader
2.4 KiB

  1. "use strict";
  2. var __importDefault = (this && this.__importDefault) || function (mod) {
  3. return (mod && mod.__esModule) ? mod : { "default": mod };
  4. };
  5. Object.defineProperty(exports, "__esModule", { value: true });
  6. const CSSStyleDeclaration_1 = __importDefault(require("../../css/declaration/CSSStyleDeclaration"));
  7. const Element_1 = __importDefault(require("../element/Element"));
  8. /**
  9. * SVG Element.
  10. *
  11. * Reference:
  12. * https://developer.mozilla.org/en-US/docs/Web/API/SVGElement.
  13. */
  14. class SVGElement extends Element_1.default {
  15. constructor() {
  16. super(...arguments);
  17. // Events
  18. this.onabort = null;
  19. this.onerror = null;
  20. this.onload = null;
  21. this.onresize = null;
  22. this.onscroll = null;
  23. this.onunload = null;
  24. this._style = null;
  25. }
  26. /**
  27. * Returns viewport.
  28. *
  29. * @returns SVG rect.
  30. */
  31. get viewportElement() {
  32. return null;
  33. }
  34. /**
  35. * Returns current translate.
  36. *
  37. * @returns Element.
  38. */
  39. get ownerSVGElement() {
  40. const parent = this.parentNode;
  41. while (parent) {
  42. if (parent['tagName'] === 'SVG') {
  43. return parent;
  44. }
  45. }
  46. return null;
  47. }
  48. /**
  49. * Returns data set.
  50. *
  51. * @returns Data set.
  52. */
  53. get dataset() {
  54. const dataset = {};
  55. for (const name of Object.keys(this._attributes)) {
  56. if (name.startsWith('data-')) {
  57. dataset[name.replace('data-', '')] = this._attributes[name].value;
  58. }
  59. }
  60. return dataset;
  61. }
  62. /**
  63. * Returns style.
  64. *
  65. * @returns Style.
  66. */
  67. get style() {
  68. if (!this._style) {
  69. this._style = new CSSStyleDeclaration_1.default(this);
  70. }
  71. return this._style;
  72. }
  73. /**
  74. * @override
  75. */
  76. setAttributeNode(attribute) {
  77. const replacedAttribute = super.setAttributeNode(attribute);
  78. if (attribute.name === 'style' && this._style) {
  79. this._style.cssText = attribute.value;
  80. }
  81. return replacedAttribute;
  82. }
  83. /**
  84. * @override
  85. */
  86. removeAttributeNode(attribute) {
  87. super.removeAttributeNode(attribute);
  88. if (attribute.name === 'style' && this._style) {
  89. this._style.cssText = '';
  90. }
  91. return attribute;
  92. }
  93. }
  94. exports.default = SVGElement;
  95. //# sourceMappingURL=SVGElement.js.map