Skip to content

Commit

Permalink
fix(platform-server): Do not delete global Event (#53659)
Browse files Browse the repository at this point in the history
This commit removes a hack that deletes `Event` from the global context
when using domino. Instead, it sets the global event to domino's
implementation of `Event`.

PR Close #53659
  • Loading branch information
atscott committed Jan 4, 2024
1 parent 5f73737 commit 91cb16f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 12 deletions.
7 changes: 1 addition & 6 deletions packages/core/test/render3/load_domino.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ if (typeof window == 'undefined') {
DominoAdapter.makeCurrent();
(global as any).document = getDOM().getDefaultDocument();

// Trick to avoid Event patching from
// https://github.com/angular/angular/blob/7cf5e95ac9f0f2648beebf0d5bd9056b79946970/packages/platform-browser/src/dom/events/dom_events.ts#L112-L132
// It fails with Domino with TypeError: Cannot assign to read only property
// 'stopImmediatePropagation' of object '#<Event>'
(global as any).Event = null;

// For animation tests, see
// https://github.com/angular/angular/blob/main/packages/animations/browser/src/render/shared.ts#L140
(global as any).Element = domino.impl.Element;
(global as any).isBrowser = false;
(global as any).isNode = true;
(global as any).Event = domino.impl.Event;
}
7 changes: 1 addition & 6 deletions packages/private/testing/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ async function loadDominoOrNull():

/**
* Ensure that global has `Document` if we are in node.js
* @publicApi
*/
export async function ensureDocument(): Promise<void> {
if ((global as any).isBrowser) {
Expand All @@ -147,11 +146,7 @@ export async function ensureDocument(): Promise<void> {
savedDocument = (global as any).document;
(global as any).window = window;
(global as any).document = window.document;
// Trick to avoid Event patching from
// https://github.com/angular/angular/blob/7cf5e95ac9f0f2648beebf0d5bd9056b79946970/packages/platform-browser/src/dom/events/dom_events.ts#L112-L132
// It fails with Domino with TypeError: Cannot assign to read only property
// 'stopImmediatePropagation' of object '#<Event>'
(global as any).Event = null;
(global as any).Event = domino.impl.Event;
savedNode = (global as any).Node;
// Domino types do not type `impl`, but it's a documented field.
// See: https://www.npmjs.com/package/domino#usage.
Expand Down

0 comments on commit 91cb16f

Please sign in to comment.