SSR ResizeObserver shim
This commit is contained in:
		
							parent
							
								
									1bb625f06b
								
							
						
					
					
						commit
						4e26e1f196
					
				@ -13,6 +13,8 @@ import { AppServerModule } from './src/main.server';
 | 
				
			|||||||
import { APP_BASE_HREF } from '@angular/common';
 | 
					import { APP_BASE_HREF } from '@angular/common';
 | 
				
			||||||
import { existsSync } from 'fs';
 | 
					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 template = fs.readFileSync(path.join(process.cwd(), 'dist/mempool/browser/en-US/', 'index.html')).toString();
 | 
				
			||||||
const win = domino.createWindow(template);
 | 
					const win = domino.createWindow(template);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -29,11 +31,13 @@ win.matchMedia = () => {
 | 
				
			|||||||
// @ts-ignore
 | 
					// @ts-ignore
 | 
				
			||||||
win.setTimeout = (fn) => { fn(); };
 | 
					win.setTimeout = (fn) => { fn(); };
 | 
				
			||||||
win.document.body.scrollTo = (() => {});
 | 
					win.document.body.scrollTo = (() => {});
 | 
				
			||||||
 | 
					win['ResizeObserver'] = ResizeObserver;
 | 
				
			||||||
// @ts-ignore
 | 
					// @ts-ignore
 | 
				
			||||||
global['window'] = win;
 | 
					global['window'] = win;
 | 
				
			||||||
global['document'] = win.document;
 | 
					global['document'] = win.document;
 | 
				
			||||||
// @ts-ignore
 | 
					// @ts-ignore
 | 
				
			||||||
global['history'] = { state: { } };
 | 
					global['history'] = { state: { } };
 | 
				
			||||||
 | 
					global['navigator'] = win.navigator;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
global['localStorage'] = {
 | 
					global['localStorage'] = {
 | 
				
			||||||
  getItem: () => '',
 | 
					  getItem: () => '',
 | 
				
			||||||
 | 
				
			|||||||
							
								
								
									
										7
									
								
								frontend/shims.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										7
									
								
								frontend/shims.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,7 @@
 | 
				
			|||||||
 | 
					export class ResizeObserver {
 | 
				
			||||||
 | 
					  constructor() {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  disconnect() {}
 | 
				
			||||||
 | 
					  observe() {}
 | 
				
			||||||
 | 
					  unobserve() {}
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user