Repository navigation
Conversation
- Defer to `globalThis.Event` and `globalThis.CustomEvent` (as well as UIEvent and MouseEvent) when available in the runtime environment. - Allow `EventTarget.prototype._dispatchEvent` to dispatch native `Event` and `CustomEvent` objects by properly defining properties (such as `target`, `currentTarget`, `isTrusted`, `eventPhase`) without failing on read-only getters. - Support native `stopPropagation()` and `stopImmediatePropagation()`. Fixes angular/angular#71977
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Modern Node.js (v18+) provides native standard implementations of
Event,CustomEvent, andEventTarget.When
@angular/platform-serverimports Domino and copiesdomino.implontoglobalThis, Domino's internalEventandCustomEventconstructors overwrite Node's native globals. This causes issues for libraries extending Node's nativeEventTarget(such asp-queuev10), because Node's nativeEventTarget.prototype.dispatchEvent()enforces an internal brand check requiring the event to be an instance of Node's nativeEvent, throwing:Furthermore, Domino's
EventTarget.prototype._dispatchEventpreviously rejected nativeEventinstances because it requiredevent._initialized === trueand directly assigned to getter-only properties (target,currentTarget,isTrusted,eventPhase).Changes
globalThis.Event/CustomEvent: Updatedlib/events.jsto defer toglobalThisevent constructors when available in the environment.lib/EventTarget.jsto:event._initialized === false.Object.definePropertyto assigntarget,currentTarget,isTrusted, andeventPhaseon events with read-only prototype getters.cancelBubbleandstopImmediatePropagation()on native events.createEventcompatibility: Fallback to passing an empty type to constructor ifnew constructor()throws due to argument length.Fixes angular/angular#71977