版博士V2.0程序
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 NodeTypeEnum_1 = __importDefault(require("../nodes/node/NodeTypeEnum"));
  7. const perf_hooks_1 = require("perf_hooks");
  8. /**
  9. * Event.
  10. */
  11. class Event {
  12. /**
  13. * Constructor.
  14. *
  15. * @param type Event type.
  16. * @param [eventInit] Event init.
  17. */
  18. constructor(type, eventInit = null) {
  19. this.composed = false;
  20. this.bubbles = false;
  21. this.cancelable = false;
  22. this.defaultPrevented = false;
  23. this._immediatePropagationStopped = false;
  24. this._propagationStopped = false;
  25. this._target = null;
  26. this._currentTarget = null;
  27. this.timeStamp = perf_hooks_1.performance.now();
  28. this.type = null;
  29. this.type = type;
  30. if (eventInit) {
  31. this.bubbles = eventInit.bubbles || false;
  32. this.cancelable = eventInit.cancelable || false;
  33. this.composed = eventInit.composed || false;
  34. }
  35. }
  36. /**
  37. * Returns target.
  38. *
  39. * @returns Target.
  40. */
  41. get target() {
  42. return this._target;
  43. }
  44. /**
  45. * Returns target.
  46. *
  47. * @returns Target.
  48. */
  49. get currentTarget() {
  50. return this._currentTarget;
  51. }
  52. /**
  53. * Returns composed path.
  54. *
  55. * @returns Composed path.
  56. */
  57. composedPath() {
  58. if (!this.target) {
  59. return [];
  60. }
  61. const composedPath = [];
  62. let eventTarget = this.target;
  63. while (eventTarget) {
  64. composedPath.push(eventTarget);
  65. if (this.bubbles) {
  66. if (this.composed &&
  67. eventTarget.nodeType === NodeTypeEnum_1.default.documentFragmentNode &&
  68. eventTarget.host) {
  69. eventTarget = eventTarget.host;
  70. }
  71. else if (this.target.ownerDocument === eventTarget) {
  72. eventTarget = this.target.ownerDocument.defaultView;
  73. }
  74. else {
  75. eventTarget = eventTarget.parentNode || null;
  76. }
  77. }
  78. }
  79. return composedPath;
  80. }
  81. /**
  82. * Init event.
  83. *
  84. * @deprecated
  85. * @param type Type.
  86. * @param [bubbles=false] "true" if it bubbles.
  87. * @param [cancelable=false] "true" if it cancelable.
  88. */
  89. initEvent(type, bubbles = false, cancelable = false) {
  90. this.type = type;
  91. this.bubbles = bubbles;
  92. this.cancelable = cancelable;
  93. }
  94. /**
  95. * Prevents default.
  96. */
  97. preventDefault() {
  98. this.defaultPrevented = true;
  99. }
  100. /**
  101. * Stops immediate propagation.
  102. */
  103. stopImmediatePropagation() {
  104. this._immediatePropagationStopped = true;
  105. }
  106. /**
  107. * Stops propagation.
  108. */
  109. stopPropagation() {
  110. this._propagationStopped = true;
  111. }
  112. }
  113. exports.default = Event;
  114. //# sourceMappingURL=Event.js.map