File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
special-pages/pages/new-tab/app/activity/mocks Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,23 @@ const url = typeof window !== 'undefined' ? new URL(window.location.href) : new
7
7
* @typedef {import('../../../types/new-tab.js').ActivityOnDataPatchSubscription['params'] } PatchParams
8
8
*/
9
9
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
+
10
19
export function activityMockTransport ( ) {
11
20
/** @type {import('../../../types/new-tab.ts').ActivityData } */
12
- let dataset = structuredClone ( activityMocks . few ) ;
21
+ let dataset = clone ( activityMocks . few ) ;
13
22
14
23
if ( url . searchParams . has ( 'activity' ) ) {
15
24
const key = url . searchParams . get ( 'activity' ) ;
16
25
if ( key && key in activityMocks ) {
17
- dataset = structuredClone ( activityMocks [ key ] ) ;
26
+ dataset = clone ( activityMocks [ key ] ) ;
18
27
} else if ( key ?. match ( / ^ \d + $ / ) ) {
19
28
dataset = getJsonSync ( parseInt ( key ) ) ;
20
29
}
You can’t perform that action at this time.
0 commit comments