Skip to content

Commit

Permalink
fix(mock-doc): provide mock for resize observer (#6007)
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-bromann authored Oct 2, 2024
1 parent dbc2f58 commit 6d6a65e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export function hydrateFactory($stencilWindow, $stencilHydrateOpts, $stencilHydr
var HTMLTemplateElement = $stencilWindow.HTMLTemplateElement;
var HTMLTitleElement = $stencilWindow.HTMLTitleElement;
var IntersectionObserver = $stencilWindow.IntersectionObserver;
var ResizeObserver = $stencilWindow.ResizeObserver;
var KeyboardEvent = $stencilWindow.KeyboardEvent;
var MouseEvent = $stencilWindow.MouseEvent;
var Node = $stencilWindow.Node;
Expand Down
21 changes: 21 additions & 0 deletions src/mock-doc/resize-observer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export class MockResizeObserver {
constructor() {
/**/
}

disconnect() {
/**/
}

observe() {
/**/
}

takeRecords(): any[] {
return [];
}

unobserve() {
/**/
}
}
5 changes: 5 additions & 0 deletions src/mock-doc/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { MockLocation } from './location';
import { MockNavigator } from './navigator';
import { MockElement, MockHTMLElement, MockNode, MockNodeList } from './node';
import { MockPerformance, resetPerformance } from './performance';
import { MockResizeObserver } from './resize-observer';
import { MockStorage } from './storage';

const nativeClearInterval = clearInterval;
Expand Down Expand Up @@ -311,6 +312,10 @@ export class MockWindow {
return MockIntersectionObserver;
}

get ResizeObserver() {
return MockResizeObserver;
}

get localStorage() {
if (this.__localStorage == null) {
this.__localStorage = new MockStorage();
Expand Down

0 comments on commit 6d6a65e

Please sign in to comment.