Skip to content

Commit 1602ae6

Browse files
committed
Set, Date, URL
1 parent ee702d1 commit 1602ae6

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

packages/svelte/src/reactivity/date.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { STATE_SNAPSHOT_SYMBOL } from '../internal/client/constants.js';
12
import { source, set } from '../internal/client/reactivity/sources.js';
23
import { get } from '../internal/client/runtime.js';
34

@@ -99,4 +100,8 @@ export class ReactiveDate extends Date {
99100
super(...values);
100101
this.#init();
101102
}
103+
104+
[STATE_SNAPSHOT_SYMBOL]() {
105+
return new Date(get(this.#raw_time));
106+
}
102107
}

packages/svelte/src/reactivity/set.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { DEV } from 'esm-env';
22
import { source, set } from '../internal/client/reactivity/sources.js';
33
import { get } from '../internal/client/runtime.js';
44
import { map } from './utils.js';
5+
import { STATE_SNAPSHOT_SYMBOL } from '../internal/client/constants.js';
6+
import { snapshot } from '../internal/client/reactivity/snapshot.js';
57

68
var read_methods = ['forEach', 'isDisjointFrom', 'isSubsetOf', 'isSupersetOf'];
79
var set_like_methods = ['difference', 'intersection', 'symmetricDifference', 'union'];
@@ -149,4 +151,9 @@ export class ReactiveSet extends Set {
149151
get size() {
150152
return get(this.#size);
151153
}
154+
155+
/** @param {boolean} deep */
156+
[STATE_SNAPSHOT_SYMBOL](deep) {
157+
return new Set(map(this.keys(), (key) => snapshot(key, deep), 'Set Iterator'));
158+
}
152159
}

packages/svelte/src/reactivity/url.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { STATE_SNAPSHOT_SYMBOL } from '../internal/client/constants.js';
12
import { source, set } from '../internal/client/reactivity/sources.js';
23
import { get } from '../internal/client/runtime.js';
34

@@ -150,6 +151,10 @@ export class ReactiveURL extends URL {
150151
toJSON() {
151152
return this.href;
152153
}
154+
155+
[STATE_SNAPSHOT_SYMBOL]() {
156+
return new URL(this.href);
157+
}
153158
}
154159

155160
export class ReactiveURLSearchParams extends URLSearchParams {

0 commit comments

Comments
 (0)