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 typing for DOMParser #8871

Merged
merged 16 commits into from
Apr 30, 2023
1 change: 1 addition & 0 deletions src/env/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export const getEnv = (): TFabricEnv => {
// noop
},
copyPasteData,
DOMParser: new window.DOMParser(),
};
};
2 changes: 2 additions & 0 deletions src/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ export const getEnv = () => env || getBrowserEnv();
export const getDocument = (): Document => getEnv().document;

export const getWindow = (): Window | DOMWindow => getEnv().window;

export const getDOMParser = () => getEnv().DOMParser;
1 change: 1 addition & 0 deletions src/env/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export const getEnv = (): TFabricEnv => {
}
},
copyPasteData,
DOMParser: new JSDOMWindow.DOMParser(),
tushuhei marked this conversation as resolved.
Show resolved Hide resolved
};
};

Expand Down
1 change: 1 addition & 0 deletions src/env/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ export type TFabricEnv = {
WebGLProbe: GLProbe;
dispose(element: Element): void;
copyPasteData: TCopyPasteData;
DOMParser: DOMParser;
tushuhei marked this conversation as resolved.
Show resolved Hide resolved
};