"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