| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -125,7 +125,7 @@ class Event { | |||
| 125 | 125 | get bubbles() { return this.#bubbles; } | |
| 126 | 126 | get composed() { return this.#composed; } | |
| 127 | 127 | get eventPhase() { | |
| 128 | - return this[kTarget] ? 2 : 0; // Equivalent to AT_TARGET or NONE | ||
| 128 | + return this[kTarget] ? Event.AT_TARGET : Event.NONE; | ||
| 129 | 129 | } | |
| 130 | 130 | get cancelBubble() { return this.#propagationStopped; } | |
| 131 | 131 | set cancelBubble(value) { | |
@@ -136,6 +136,11 @@ class Event { | |||
| 136 | 136 | stopPropagation() { | |
| 137 | 137 | this.#propagationStopped = true; | |
| 138 | 138 | } | |
| 139 | + | ||
| 140 | + static NONE = 0; | ||
| 141 | + static CAPTURING_PHASE = 1; | ||
| 142 | + static AT_TARGET = 2; | ||
| 143 | + static BUBBLING_PHASE = 3; | ||
| 139 | 144 | } | |
| 140 | 145 | ||
| 141 | 146 | Object.defineProperty(Event.prototype, SymbolToStringTag, { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -432,7 +432,6 @@ ok(EventTarget); | |||
| 432 | 432 | target.removeEventListener('foo', a, { capture: false }); | |
| 433 | 433 | target.dispatchEvent(new Event('foo')); | |
| 434 | 434 | } | |
| 435 | - | ||
| 436 | 435 | { | |
| 437 | 436 | const target = new EventTarget(); | |
| 438 | 437 | strictEqual(target.toString(), '[object EventTarget]'); | |
@@ -464,3 +463,16 @@ ok(EventTarget); | |||
| 464 | 463 | }); | |
| 465 | 464 | }); | |
| 466 | 465 | } | |
| 466 | + | ||
| 467 | + { | ||
| 468 | + strictEqual(Event.NONE, 0); | ||
| 469 | + strictEqual(Event.CAPTURING_PHASE, 1); | ||
| 470 | + strictEqual(Event.AT_TARGET, 2); | ||
| 471 | + strictEqual(Event.BUBBLING_PHASE, 3); | ||
| 472 | + strictEqual(new Event('foo').eventPhase, Event.NONE); | ||
| 473 | + const target = new EventTarget(); | ||
| 474 | + target.addEventListener('foo', common.mustCall((e) => { | ||
| 475 | + strictEqual(e.eventPhase, Event.AT_TARGET); | ||
| 476 | + }), { once: true }); | ||
| 477 | + target.dispatchEvent(new Event('foo')); | ||
| 478 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments