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: replace structuredClone with Object.assign #258

Merged
merged 2 commits into from
Nov 6, 2023
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
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ module.exports = {
'@typescript-eslint/prefer-for-of': 'off',
'@typescript-eslint/dot-notation': 'off',
'@typescript-eslint/member-ordering': 'off',
'prefer-object-spread': 'warn',

// Disable the async generator warning
'no-restricted-syntax': 'off',
Expand Down
6 changes: 4 additions & 2 deletions packages/common/src/dotlottie-player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,8 @@
container?: DotLottieElement | null,
options?: DotLottieConfig<RendererType>,
) {
this._src = structuredClone(src);
if (typeof src === 'string') this._src = src;
else this._src = Object.assign({}, src);

Check warning on line 218 in packages/common/src/dotlottie-player.ts

View workflow job for this annotation

GitHub Actions / validate

Use an object spread instead of `Object.assign` eg: `{ ...foo }`
yash1200 marked this conversation as resolved.
Show resolved Hide resolved

if (options?.testId) {
this._testId = options.testId;
Expand Down Expand Up @@ -482,7 +483,8 @@

public updateSrc(src: Record<string, unknown> | string): void {
if (this._src === src) return;
this._src = structuredClone(src);
if (typeof src === 'string') this._src = src;
else this._src = Object.assign({}, src);

Check warning on line 487 in packages/common/src/dotlottie-player.ts

View workflow job for this annotation

GitHub Actions / validate

Use an object spread instead of `Object.assign` eg: `{ ...foo }`
yash1200 marked this conversation as resolved.
Show resolved Hide resolved
this._activeAnimationId = undefined;
this._currentAnimationId = undefined;
this.load();
Expand Down Expand Up @@ -1848,7 +1850,7 @@
'Worker is only supported with svg renderer. Change or remove renderer prop to get rid of this warning.',
);
}
// @ts-ignore

Check warning on line 1853 in packages/common/src/dotlottie-player.ts

View workflow job for this annotation

GitHub Actions / validate

Do not use "@ts-ignore" because it alters compilation errors
LottieWebModule = await import(`lottie-web/build/player/lottie_worker`);

return LottieWebModule.default;
Expand All @@ -1868,7 +1870,7 @@
if (this._light) {
LottieWebModule = await import(`lottie-web/build/player/lottie_light_canvas`);
} else {
// @ts-ignore

Check warning on line 1873 in packages/common/src/dotlottie-player.ts

View workflow job for this annotation

GitHub Actions / validate

Do not use "@ts-ignore" because it alters compilation errors
LottieWebModule = await import(`lottie-web/build/player/lottie_canvas`);
}

Expand Down
Loading