| 97 | } |
| 98 | |
| 99 | class Event { |
| 100 | #cancelable = false; |
| 101 | #bubbles = false; |
| 102 | #composed = false; |
| 103 | #defaultPrevented = false; |
| 104 | #timestamp = now(); |
| 105 | #propagationStopped = false; |
| 106 | |
| 107 | /** |
| 108 | * @param {string} type |
| 109 | * @param {{ |
| 110 | * bubbles?: boolean, |
| 111 | * cancelable?: boolean, |
| 112 | * composed?: boolean, |
| 113 | * }} [options] |
| 114 | */ |
| 115 | constructor(type, options = undefined) { |
| 116 | if (arguments.length === 0) |
| 117 | throw new ERR_MISSING_ARGS('type'); |
| 118 | if (options != null) |
| 119 | validateObject(options, 'options'); |
| 120 | this.#bubbles = !!options?.bubbles; |
| 121 | this.#cancelable = !!options?.cancelable; |
| 122 | this.#composed = !!options?.composed; |
| 123 | |
| 124 | this[kType] = `${type}`; |
| 125 | if (options?.[kTrustEvent]) { |
| 126 | isTrustedSet.add(this); |
| 127 | } |
| 128 | |
| 129 | this[kTarget] = null; |
| 130 | this[kIsBeingDispatched] = false; |
| 131 | this[kInPassiveListener] = false; |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * @param {string} type |
| 136 | * @param {boolean} [bubbles] |
| 137 | * @param {boolean} [cancelable] |
| 138 | */ |
| 139 | initEvent(type, bubbles = false, cancelable = false) { |
| 140 | if (arguments.length === 0) |
| 141 | throw new ERR_MISSING_ARGS('type'); |
| 142 | |
| 143 | if (this[kIsBeingDispatched]) { |
| 144 | return; |
| 145 | } |
| 146 | this[kType] = `${type}`; |
| 147 | this.#bubbles = !!bubbles; |
| 148 | this.#cancelable = !!cancelable; |
| 149 | } |
| 150 | |
| 151 | [customInspectSymbol](depth, options) { |
| 152 | if (!isEvent(this)) |
| 153 | throw new ERR_INVALID_THIS('Event'); |
| 154 | const name = this.constructor.name; |
| 155 | if (depth < 0) |
| 156 | return name; |
no test coverage detected
searching dependent graphs…