Skip to content

Commit d0ca2db

Browse files
committed
clone on big sur
1 parent 7b948ae commit d0ca2db

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

special-pages/pages/new-tab/app/activity/mocks/activity.mock-transport.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@ const url = typeof window !== 'undefined' ? new URL(window.location.href) : new
77
* @typedef {import('../../../types/new-tab.js').ActivityOnDataPatchSubscription['params']} PatchParams
88
*/
99

10+
/**
11+
* @template T
12+
* @param {T} value
13+
* @return {T}
14+
*/
15+
function clone(value) {
16+
return window.structuredClone?.(value) ?? JSON.parse(JSON.stringify(value));
17+
}
18+
1019
export function activityMockTransport() {
1120
/** @type {import('../../../types/new-tab.ts').ActivityData} */
12-
let dataset = structuredClone(activityMocks.few);
21+
let dataset = clone(activityMocks.few);
1322

1423
if (url.searchParams.has('activity')) {
1524
const key = url.searchParams.get('activity');
1625
if (key && key in activityMocks) {
17-
dataset = structuredClone(activityMocks[key]);
26+
dataset = clone(activityMocks[key]);
1827
} else if (key?.match(/^\d+$/)) {
1928
dataset = getJsonSync(parseInt(key));
2029
}

0 commit comments

Comments
 (0)