Skip to content

Commit 635d61e

Browse files
committed
fix(@nguniversal/common): add Window stubs to Engine (Clover)
Closes angular#2108
1 parent e978c28 commit 635d61e

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

modules/common/clover/server/src/server-engine.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import * as path from 'path';
1616
import { URL } from 'url';
1717
import { CustomResourceLoader } from './custom-resource-loader';
1818
import { InlineCriticalCssProcessor } from './inline-css-processor';
19+
import { augmentWindowWithStubs } from './stubs';
1920

2021
export interface RenderOptions {
2122
headers?: Record<string, string | undefined | string[]>;
@@ -73,6 +74,7 @@ export class Engine {
7374
referrer: options.headers?.referrer as string | undefined,
7475
userAgent: options.headers?.['user-agent'] as string | undefined,
7576
beforeParse: (window) => {
77+
augmentWindowWithStubs(window);
7678
window.ngRenderMode = true;
7779
},
7880
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @license
3+
* Copyright Google LLC All Rights Reserved.
4+
*
5+
* Use of this source code is governed by an MIT-style license that can be
6+
* found in the LICENSE file at https://angular.io/license
7+
*/
8+
9+
import { DOMWindow } from 'jsdom';
10+
11+
function noop(): void {}
12+
13+
export function augmentWindowWithStubs(window: DOMWindow): void {
14+
window.resizeBy = noop;
15+
window.resizeTo = noop;
16+
window.scroll = noop;
17+
window.scrollBy = noop;
18+
window.scrollTo = noop;
19+
}

0 commit comments

Comments
 (0)