Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(mock-doc): provide mock for resize observer #6007

Merged
merged 1 commit into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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