SSR ResizeObserver shim

This commit is contained in:
Mononaut 2023-10-18 17:58:35 +00:00
parent 1bb625f06b
commit 4e26e1f196
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
2 changed files with 11 additions and 0 deletions

View File

@ -13,6 +13,8 @@ import { AppServerModule } from './src/main.server';
import { APP_BASE_HREF } from '@angular/common';
import { existsSync } from 'fs';
import { ResizeObserver } from './shims';
const template = fs.readFileSync(path.join(process.cwd(), 'dist/mempool/browser/en-US/', 'index.html')).toString();
const win = domino.createWindow(template);
@ -29,11 +31,13 @@ win.matchMedia = () => {
// @ts-ignore
win.setTimeout = (fn) => { fn(); };
win.document.body.scrollTo = (() => {});
win['ResizeObserver'] = ResizeObserver;
// @ts-ignore
global['window'] = win;
global['document'] = win.document;
// @ts-ignore
global['history'] = { state: { } };
global['navigator'] = win.navigator;
global['localStorage'] = {
getItem: () => '',

7
frontend/shims.ts Normal file
View File

@ -0,0 +1,7 @@
export class ResizeObserver {
constructor() {}
disconnect() {}
observe() {}
unobserve() {}
}