|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- "use strict";
- var __importDefault = (this && this.__importDefault) || function (mod) {
- return (mod && mod.__esModule) ? mod : { "default": mod };
- };
- Object.defineProperty(exports, "__esModule", { value: true });
- const NodeTypeEnum_1 = __importDefault(require("../nodes/node/NodeTypeEnum"));
- const perf_hooks_1 = require("perf_hooks");
- /**
- * Event.
- */
- class Event {
- /**
- * Constructor.
- *
- * @param type Event type.
- * @param [eventInit] Event init.
- */
- constructor(type, eventInit = null) {
- this.composed = false;
- this.bubbles = false;
- this.cancelable = false;
- this.defaultPrevented = false;
- this._immediatePropagationStopped = false;
- this._propagationStopped = false;
- this._target = null;
- this._currentTarget = null;
- this.timeStamp = perf_hooks_1.performance.now();
- this.type = null;
- this.type = type;
- if (eventInit) {
- this.bubbles = eventInit.bubbles || false;
- this.cancelable = eventInit.cancelable || false;
- this.composed = eventInit.composed || false;
- }
- }
- /**
- * Returns target.
- *
- * @returns Target.
- */
- get target() {
- return this._target;
- }
- /**
- * Returns target.
- *
- * @returns Target.
- */
- get currentTarget() {
- return this._currentTarget;
- }
- /**
- * Returns composed path.
- *
- * @returns Composed path.
- */
- composedPath() {
- if (!this.target) {
- return [];
- }
- const composedPath = [];
- let eventTarget = this.target;
- while (eventTarget) {
- composedPath.push(eventTarget);
- if (this.bubbles) {
- if (this.composed &&
- eventTarget.nodeType === NodeTypeEnum_1.default.documentFragmentNode &&
- eventTarget.host) {
- eventTarget = eventTarget.host;
- }
- else if (this.target.ownerDocument === eventTarget) {
- eventTarget = this.target.ownerDocument.defaultView;
- }
- else {
- eventTarget = eventTarget.parentNode || null;
- }
- }
- }
- return composedPath;
- }
- /**
- * Init event.
- *
- * @deprecated
- * @param type Type.
- * @param [bubbles=false] "true" if it bubbles.
- * @param [cancelable=false] "true" if it cancelable.
- */
- initEvent(type, bubbles = false, cancelable = false) {
- this.type = type;
- this.bubbles = bubbles;
- this.cancelable = cancelable;
- }
- /**
- * Prevents default.
- */
- preventDefault() {
- this.defaultPrevented = true;
- }
- /**
- * Stops immediate propagation.
- */
- stopImmediatePropagation() {
- this._immediatePropagationStopped = true;
- }
- /**
- * Stops propagation.
- */
- stopPropagation() {
- this._propagationStopped = true;
- }
- }
- exports.default = Event;
- //# sourceMappingURL=Event.js.map
|