ripple 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/package.json +2 -2
- package/src/compiler/phases/1-parse/index.js +37 -194
- package/src/compiler/phases/2-analyze/index.js +63 -18
- package/src/compiler/phases/3-transform/client/index.js +19 -3
- package/src/compiler/phases/3-transform/server/index.js +16 -24
- package/src/compiler/types/parse.d.ts +0 -8
- package/src/runtime/internal/client/composite.js +2 -2
- package/tests/client/array/array.copy-within.test.ripple +12 -12
- package/tests/client/array/array.derived.test.ripple +46 -46
- package/tests/client/array/array.iteration.test.ripple +10 -10
- package/tests/client/array/array.mutations.test.ripple +20 -20
- package/tests/client/array/array.to-methods.test.ripple +6 -6
- package/tests/client/async-suspend.test.ripple +5 -5
- package/tests/client/basic/basic.attributes.test.ripple +81 -81
- package/tests/client/basic/basic.collections.test.ripple +9 -9
- package/tests/client/basic/basic.components.test.ripple +28 -28
- package/tests/client/basic/basic.errors.test.ripple +18 -18
- package/tests/client/basic/basic.events.test.ripple +37 -37
- package/tests/client/basic/basic.get-set.test.ripple +6 -6
- package/tests/client/basic/basic.reactivity.test.ripple +68 -68
- package/tests/client/basic/basic.rendering.test.ripple +19 -19
- package/tests/client/basic/basic.utilities.test.ripple +3 -3
- package/tests/client/boundaries.test.ripple +12 -12
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.ripple.snap +5 -5
- package/tests/client/compiler/compiler.assignments.test.ripple +19 -19
- package/tests/client/compiler/compiler.basic.test.ripple +16 -16
- package/tests/client/compiler/compiler.tracked-access.test.ripple +2 -2
- package/tests/client/composite/composite.dynamic-components.test.ripple +9 -9
- package/tests/client/composite/composite.props.test.ripple +11 -11
- package/tests/client/composite/composite.reactivity.test.ripple +43 -43
- package/tests/client/composite/composite.render.test.ripple +3 -3
- package/tests/client/computed-properties.test.ripple +4 -4
- package/tests/client/date.test.ripple +42 -42
- package/tests/client/dynamic-elements.test.ripple +42 -42
- package/tests/client/events.test.ripple +70 -70
- package/tests/client/for.test.ripple +25 -25
- package/tests/client/head.test.ripple +19 -19
- package/tests/client/html.test.ripple +3 -3
- package/tests/client/input-value.test.ripple +84 -84
- package/tests/client/lazy-destructuring.test.ripple +71 -16
- package/tests/client/map.test.ripple +16 -16
- package/tests/client/media-query.test.ripple +7 -7
- package/tests/client/portal.test.ripple +11 -11
- package/tests/client/ref.test.ripple +4 -4
- package/tests/client/return.test.ripple +52 -52
- package/tests/client/set.test.ripple +6 -6
- package/tests/client/svg.test.ripple +5 -5
- package/tests/client/switch.test.ripple +44 -44
- package/tests/client/try.test.ripple +5 -5
- package/tests/client/url/url.derived.test.ripple +6 -6
- package/tests/client/url-search-params/url-search-params.derived.test.ripple +8 -8
- package/tests/client/url-search-params/url-search-params.iteration.test.ripple +10 -10
- package/tests/client/url-search-params/url-search-params.mutation.test.ripple +10 -10
- package/tests/client/url-search-params/url-search-params.retrieval.test.ripple +18 -18
- package/tests/client/url-search-params/url-search-params.serialization.test.ripple +2 -2
- package/tests/hydration/compiled/client/events.js +25 -25
- package/tests/hydration/compiled/client/for.js +70 -66
- package/tests/hydration/compiled/client/head.js +25 -25
- package/tests/hydration/compiled/client/hmr.js +2 -2
- package/tests/hydration/compiled/client/html.js +3 -3
- package/tests/hydration/compiled/client/if-children.js +24 -24
- package/tests/hydration/compiled/client/if.js +18 -18
- package/tests/hydration/compiled/client/mixed-control-flow.js +9 -9
- package/tests/hydration/compiled/client/portal.js +3 -3
- package/tests/hydration/compiled/client/reactivity.js +16 -16
- package/tests/hydration/compiled/client/return.js +40 -40
- package/tests/hydration/compiled/client/switch.js +12 -12
- package/tests/hydration/compiled/server/events.js +19 -19
- package/tests/hydration/compiled/server/for.js +41 -41
- package/tests/hydration/compiled/server/head.js +26 -26
- package/tests/hydration/compiled/server/hmr.js +2 -2
- package/tests/hydration/compiled/server/html.js +2 -2
- package/tests/hydration/compiled/server/if-children.js +16 -16
- package/tests/hydration/compiled/server/if.js +11 -11
- package/tests/hydration/compiled/server/mixed-control-flow.js +6 -6
- package/tests/hydration/compiled/server/portal.js +2 -2
- package/tests/hydration/compiled/server/reactivity.js +16 -16
- package/tests/hydration/compiled/server/return.js +25 -25
- package/tests/hydration/compiled/server/switch.js +8 -8
- package/tests/hydration/components/events.ripple +25 -25
- package/tests/hydration/components/for.ripple +66 -66
- package/tests/hydration/components/head.ripple +16 -16
- package/tests/hydration/components/hmr.ripple +2 -2
- package/tests/hydration/components/html.ripple +3 -3
- package/tests/hydration/components/if-children.ripple +24 -24
- package/tests/hydration/components/if.ripple +18 -18
- package/tests/hydration/components/mixed-control-flow.ripple +9 -9
- package/tests/hydration/components/portal.ripple +3 -3
- package/tests/hydration/components/reactivity.ripple +16 -16
- package/tests/hydration/components/return.ripple +40 -40
- package/tests/hydration/components/switch.ripple +20 -20
- package/tests/server/await.test.ripple +3 -3
- package/tests/server/basic.attributes.test.ripple +34 -34
- package/tests/server/basic.components.test.ripple +10 -10
- package/tests/server/basic.test.ripple +38 -40
- package/tests/server/composite.props.test.ripple +9 -9
- package/tests/server/dynamic-elements.test.ripple +13 -12
- package/tests/server/head.test.ripple +11 -11
- package/tests/server/lazy-destructuring.test.ripple +27 -4
|
@@ -7,10 +7,10 @@ describe('composite > reactivity', () => {
|
|
|
7
7
|
<button
|
|
8
8
|
class="count2"
|
|
9
9
|
onClick={() => {
|
|
10
|
-
obj
|
|
10
|
+
obj.count.value++;
|
|
11
11
|
}}
|
|
12
12
|
>
|
|
13
|
-
{obj
|
|
13
|
+
{obj.count.value}
|
|
14
14
|
</button>
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -20,7 +20,7 @@ describe('composite > reactivity', () => {
|
|
|
20
20
|
count: track(0),
|
|
21
21
|
};
|
|
22
22
|
|
|
23
|
-
<span class="count">{obj
|
|
23
|
+
<span class="count">{obj.count.value}</span>
|
|
24
24
|
<Button {obj} />
|
|
25
25
|
</div>
|
|
26
26
|
}
|
|
@@ -41,15 +41,15 @@ describe('composite > reactivity', () => {
|
|
|
41
41
|
<button
|
|
42
42
|
class="count2"
|
|
43
43
|
onClick={() => {
|
|
44
|
-
obj
|
|
44
|
+
obj.count.value++;
|
|
45
45
|
}}
|
|
46
46
|
>
|
|
47
|
-
{obj
|
|
47
|
+
{obj.count.value}
|
|
48
48
|
</button>
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
component OtherComponent({ obj }: { obj: { count: Tracked<number> } }) {
|
|
52
|
-
<div class="count3">{obj
|
|
52
|
+
<div class="count3">{obj.count.value}</div>
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
component App() {
|
|
@@ -58,7 +58,7 @@ describe('composite > reactivity', () => {
|
|
|
58
58
|
count: track(0),
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
<span class="count">{obj
|
|
61
|
+
<span class="count">{obj.count.value}</span>
|
|
62
62
|
<span>{' '}</span>
|
|
63
63
|
if (obj) {
|
|
64
64
|
<Button {obj} />
|
|
@@ -84,28 +84,28 @@ describe('composite > reactivity', () => {
|
|
|
84
84
|
|
|
85
85
|
it('parents and children have isolated state', () => {
|
|
86
86
|
component Button(props: { count: number }) {
|
|
87
|
-
let count = track(() => props.count);
|
|
87
|
+
let &[count] = track(() => props.count);
|
|
88
88
|
<button
|
|
89
89
|
onClick={() => {
|
|
90
|
-
|
|
90
|
+
count++;
|
|
91
91
|
}}
|
|
92
92
|
>
|
|
93
|
-
{'child: ' +
|
|
93
|
+
{'child: ' + count}
|
|
94
94
|
</button>
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
component App() {
|
|
98
98
|
<div>
|
|
99
|
-
let count = track(0);
|
|
99
|
+
let &[count] = track(0);
|
|
100
100
|
|
|
101
101
|
<button
|
|
102
102
|
onClick={() => {
|
|
103
|
-
|
|
103
|
+
count++;
|
|
104
104
|
}}
|
|
105
105
|
>
|
|
106
|
-
{'parent: ' +
|
|
106
|
+
{'parent: ' + count}
|
|
107
107
|
</button>
|
|
108
|
-
<Button {
|
|
108
|
+
<Button {count} />
|
|
109
109
|
</div>
|
|
110
110
|
}
|
|
111
111
|
|
|
@@ -131,28 +131,28 @@ describe('composite > reactivity', () => {
|
|
|
131
131
|
|
|
132
132
|
it('parents and children have isolated connected state (destructured props)', () => {
|
|
133
133
|
component Button(&{ count }: { count: number }) {
|
|
134
|
-
let local_count = track(() => count);
|
|
134
|
+
let &[local_count] = track(() => count);
|
|
135
135
|
<button
|
|
136
136
|
onClick={() => {
|
|
137
|
-
|
|
137
|
+
local_count++;
|
|
138
138
|
}}
|
|
139
139
|
>
|
|
140
|
-
{'child: ' +
|
|
140
|
+
{'child: ' + local_count}
|
|
141
141
|
</button>
|
|
142
142
|
}
|
|
143
143
|
|
|
144
144
|
component App() {
|
|
145
145
|
<div>
|
|
146
|
-
let count = track(0);
|
|
146
|
+
let &[count] = track(0);
|
|
147
147
|
|
|
148
148
|
<button
|
|
149
149
|
onClick={() => {
|
|
150
|
-
|
|
150
|
+
count++;
|
|
151
151
|
}}
|
|
152
152
|
>
|
|
153
|
-
{'parent: ' +
|
|
153
|
+
{'parent: ' + count}
|
|
154
154
|
</button>
|
|
155
|
-
<Button {
|
|
155
|
+
<Button {count} />
|
|
156
156
|
</div>
|
|
157
157
|
}
|
|
158
158
|
|
|
@@ -180,25 +180,25 @@ describe('composite > reactivity', () => {
|
|
|
180
180
|
let logs: string[] = [];
|
|
181
181
|
|
|
182
182
|
component App() {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
183
|
+
let &[a] = track(1);
|
|
184
|
+
let &[b] = track(2);
|
|
185
|
+
let &[c] = track(3);
|
|
186
186
|
|
|
187
|
-
|
|
187
|
+
let &[obj] = track(
|
|
188
188
|
() => ({
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
189
|
+
a,
|
|
190
|
+
b,
|
|
191
|
+
c,
|
|
192
192
|
}),
|
|
193
193
|
);
|
|
194
194
|
|
|
195
|
-
<Child {
|
|
195
|
+
<Child {...obj} />
|
|
196
196
|
|
|
197
197
|
<button
|
|
198
198
|
onClick={() => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
199
|
+
a++;
|
|
200
|
+
b++;
|
|
201
|
+
c++;
|
|
202
202
|
}}
|
|
203
203
|
>
|
|
204
204
|
{'Increment all'}
|
|
@@ -231,8 +231,8 @@ describe('composite > reactivity', () => {
|
|
|
231
231
|
'keeps reactivity for spread props via intermediate components and usage of trackSplit()',
|
|
232
232
|
() => {
|
|
233
233
|
component App() {
|
|
234
|
-
|
|
235
|
-
<CounterWrapper {
|
|
234
|
+
let &[count] = track(0);
|
|
235
|
+
<CounterWrapper {count} up={() => count++} down={() => count--} />
|
|
236
236
|
}
|
|
237
237
|
|
|
238
238
|
component CounterWrapper(props: Props) {
|
|
@@ -242,10 +242,10 @@ describe('composite > reactivity', () => {
|
|
|
242
242
|
}
|
|
243
243
|
|
|
244
244
|
component Counter(props: Props) {
|
|
245
|
-
|
|
246
|
-
<button onClick={() =>
|
|
247
|
-
<button onClick={() =>
|
|
248
|
-
<span {
|
|
245
|
+
let [count, up, down, rest] = trackSplit(props, ['count', 'up', 'down']);
|
|
246
|
+
<button onClick={() => up.value()}>{'UP'}</button>
|
|
247
|
+
<button onClick={() => down.value()}>{'DOWN'}</button>
|
|
248
|
+
<span {...rest.value}>{`Counter: ${count.value}`}</span>
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
render(App);
|
|
@@ -270,8 +270,8 @@ describe('composite > reactivity', () => {
|
|
|
270
270
|
|
|
271
271
|
it('keeps reactivity on elements for element spreads and adds / removes dynamic props', () => {
|
|
272
272
|
component App() {
|
|
273
|
-
|
|
274
|
-
<CounterWrapper {
|
|
273
|
+
let &[count] = track(0);
|
|
274
|
+
<CounterWrapper {count} up={() => count++} />
|
|
275
275
|
}
|
|
276
276
|
|
|
277
277
|
component CounterWrapper(props: { count: number; up: () => void }) {
|
|
@@ -302,9 +302,9 @@ describe('composite > reactivity', () => {
|
|
|
302
302
|
another?: number;
|
|
303
303
|
extra: number;
|
|
304
304
|
}) {
|
|
305
|
-
|
|
306
|
-
<div {
|
|
307
|
-
<button onClick={() =>
|
|
305
|
+
let [count, up, rest] = trackSplit(props, ['count', 'up']);
|
|
306
|
+
<div {...rest.value}>{`Counter: ${count.value} Double: ${props.double.value}`}</div>
|
|
307
|
+
<button onClick={() => up.value()}>{'UP'}</button>
|
|
308
308
|
}
|
|
309
309
|
|
|
310
310
|
render(App);
|
|
@@ -7,10 +7,10 @@ describe('composite > render', () => {
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
component App() {
|
|
10
|
-
let count = track(0);
|
|
10
|
+
let &[count] = track(0);
|
|
11
11
|
|
|
12
|
-
<button onClick={() =>
|
|
13
|
-
<Button {
|
|
12
|
+
<button onClick={() => count++}>{'Increment'}</button>
|
|
13
|
+
<Button {count} />
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
render(App);
|
|
@@ -7,11 +7,11 @@ describe('computed tracked properties', () => {
|
|
|
7
7
|
[0]: track(0),
|
|
8
8
|
};
|
|
9
9
|
|
|
10
|
-
<div>{obj
|
|
10
|
+
<div>{obj[0].value}</div>
|
|
11
11
|
|
|
12
12
|
<button
|
|
13
13
|
onClick={() => {
|
|
14
|
-
obj
|
|
14
|
+
obj[0].value += 1;
|
|
15
15
|
}}
|
|
16
16
|
>
|
|
17
17
|
{'Increment'}
|
|
@@ -34,11 +34,11 @@ describe('computed tracked properties', () => {
|
|
|
34
34
|
[0]: track(0),
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
<div>{obj
|
|
37
|
+
<div>{obj[0].value}</div>
|
|
38
38
|
|
|
39
39
|
<button
|
|
40
40
|
onClick={() => {
|
|
41
|
-
obj
|
|
41
|
+
obj[0].value++;
|
|
42
42
|
}}
|
|
43
43
|
>
|
|
44
44
|
{'Increment'}
|
|
@@ -4,10 +4,10 @@ describe('RippleDate', () => {
|
|
|
4
4
|
it('handles getTime() with reactive updates', () => {
|
|
5
5
|
component DateTest() {
|
|
6
6
|
let date = RippleDate(2025, 0, 1);
|
|
7
|
-
let time = track(() => date.getTime());
|
|
7
|
+
let &[time] = track(() => date.getTime());
|
|
8
8
|
|
|
9
9
|
<button onClick={() => date.setFullYear(2026)}>{'Change Year'}</button>
|
|
10
|
-
<pre>{
|
|
10
|
+
<pre>{time}</pre>
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
render(DateTest);
|
|
@@ -26,10 +26,10 @@ describe('RippleDate', () => {
|
|
|
26
26
|
it('handles getFullYear() with reactive updates', () => {
|
|
27
27
|
component DateTest() {
|
|
28
28
|
let date = RippleDate(2025, 5, 15);
|
|
29
|
-
let year = track(() => date.getFullYear());
|
|
29
|
+
let &[year] = track(() => date.getFullYear());
|
|
30
30
|
|
|
31
31
|
<button onClick={() => date.setFullYear(2030)}>{'Change Year'}</button>
|
|
32
|
-
<pre>{
|
|
32
|
+
<pre>{year}</pre>
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
render(DateTest);
|
|
@@ -47,10 +47,10 @@ describe('RippleDate', () => {
|
|
|
47
47
|
it('handles getMonth() with reactive updates', () => {
|
|
48
48
|
component DateTest() {
|
|
49
49
|
let date = RippleDate(2025, 0, 15);
|
|
50
|
-
let month = track(() => date.getMonth());
|
|
50
|
+
let &[month] = track(() => date.getMonth());
|
|
51
51
|
|
|
52
52
|
<button onClick={() => date.setMonth(11)}>{'Change to December'}</button>
|
|
53
|
-
<pre>{
|
|
53
|
+
<pre>{month}</pre>
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
render(DateTest);
|
|
@@ -68,10 +68,10 @@ describe('RippleDate', () => {
|
|
|
68
68
|
it('handles getDate() with reactive updates', () => {
|
|
69
69
|
component DateTest() {
|
|
70
70
|
let date = RippleDate(2025, 0, 1);
|
|
71
|
-
let day = track(() => date.getDate());
|
|
71
|
+
let &[day] = track(() => date.getDate());
|
|
72
72
|
|
|
73
73
|
<button onClick={() => date.setDate(15)}>{'Change Day'}</button>
|
|
74
|
-
<pre>{
|
|
74
|
+
<pre>{day}</pre>
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
render(DateTest);
|
|
@@ -89,10 +89,10 @@ describe('RippleDate', () => {
|
|
|
89
89
|
it('handles getDay() with reactive updates', () => {
|
|
90
90
|
component DateTest() {
|
|
91
91
|
let date = RippleDate(2025, 0, 1);
|
|
92
|
-
let dayOfWeek = track(() => date.getDay());
|
|
92
|
+
let &[dayOfWeek] = track(() => date.getDay());
|
|
93
93
|
|
|
94
94
|
<button onClick={() => date.setDate(2)}>{'Next Day'}</button>
|
|
95
|
-
<pre>{
|
|
95
|
+
<pre>{dayOfWeek}</pre>
|
|
96
96
|
}
|
|
97
97
|
|
|
98
98
|
render(DateTest);
|
|
@@ -110,10 +110,10 @@ describe('RippleDate', () => {
|
|
|
110
110
|
it('handles getHours() with reactive updates', () => {
|
|
111
111
|
component DateTest() {
|
|
112
112
|
let date = RippleDate(2025, 0, 1, 10, 30, 0);
|
|
113
|
-
let hours = track(() => date.getHours());
|
|
113
|
+
let &[hours] = track(() => date.getHours());
|
|
114
114
|
|
|
115
115
|
<button onClick={() => date.setHours(15)}>{'Change to 3 PM'}</button>
|
|
116
|
-
<pre>{
|
|
116
|
+
<pre>{hours}</pre>
|
|
117
117
|
}
|
|
118
118
|
|
|
119
119
|
render(DateTest);
|
|
@@ -131,10 +131,10 @@ describe('RippleDate', () => {
|
|
|
131
131
|
it('handles getMinutes() with reactive updates', () => {
|
|
132
132
|
component DateTest() {
|
|
133
133
|
let date = RippleDate(2025, 0, 1, 10, 15, 0);
|
|
134
|
-
let minutes = track(() => date.getMinutes());
|
|
134
|
+
let &[minutes] = track(() => date.getMinutes());
|
|
135
135
|
|
|
136
136
|
<button onClick={() => date.setMinutes(45)}>{'Change Minutes'}</button>
|
|
137
|
-
<pre>{
|
|
137
|
+
<pre>{minutes}</pre>
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
render(DateTest);
|
|
@@ -152,10 +152,10 @@ describe('RippleDate', () => {
|
|
|
152
152
|
it('handles getSeconds() with reactive updates', () => {
|
|
153
153
|
component DateTest() {
|
|
154
154
|
let date = RippleDate(2025, 0, 1, 10, 15, 30);
|
|
155
|
-
let seconds = track(() => date.getSeconds());
|
|
155
|
+
let &[seconds] = track(() => date.getSeconds());
|
|
156
156
|
|
|
157
157
|
<button onClick={() => date.setSeconds(45)}>{'Change Seconds'}</button>
|
|
158
|
-
<pre>{
|
|
158
|
+
<pre>{seconds}</pre>
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
render(DateTest);
|
|
@@ -173,10 +173,10 @@ describe('RippleDate', () => {
|
|
|
173
173
|
it('handles toISOString() with reactive updates', () => {
|
|
174
174
|
component DateTest() {
|
|
175
175
|
let date = RippleDate(2025, 0, 1, 12, 0, 0);
|
|
176
|
-
let isoString = track(() => date.toISOString());
|
|
176
|
+
let &[isoString] = track(() => date.toISOString());
|
|
177
177
|
|
|
178
178
|
<button onClick={() => date.setFullYear(2026)}>{'Change Year'}</button>
|
|
179
|
-
<pre>{
|
|
179
|
+
<pre>{isoString}</pre>
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
render(DateTest);
|
|
@@ -199,10 +199,10 @@ describe('RippleDate', () => {
|
|
|
199
199
|
it('handles toDateString() with reactive updates', () => {
|
|
200
200
|
component DateTest() {
|
|
201
201
|
let date = RippleDate(2025, 0, 1);
|
|
202
|
-
let dateString = track(() => date.toDateString());
|
|
202
|
+
let &[dateString] = track(() => date.toDateString());
|
|
203
203
|
|
|
204
204
|
<button onClick={() => date.setMonth(11)}>{'Change to December'}</button>
|
|
205
|
-
<pre>{
|
|
205
|
+
<pre>{dateString}</pre>
|
|
206
206
|
}
|
|
207
207
|
|
|
208
208
|
render(DateTest);
|
|
@@ -223,10 +223,10 @@ describe('RippleDate', () => {
|
|
|
223
223
|
it('handles valueOf() with reactive updates', () => {
|
|
224
224
|
component DateTest() {
|
|
225
225
|
let date = RippleDate(2025, 0, 1);
|
|
226
|
-
let valueOf = track(() => date.valueOf());
|
|
226
|
+
let &[valueOf] = track(() => date.valueOf());
|
|
227
227
|
|
|
228
228
|
<button onClick={() => date.setDate(2)}>{'Next Day'}</button>
|
|
229
|
-
<pre>{
|
|
229
|
+
<pre>{valueOf}</pre>
|
|
230
230
|
}
|
|
231
231
|
|
|
232
232
|
render(DateTest);
|
|
@@ -245,29 +245,29 @@ describe('RippleDate', () => {
|
|
|
245
245
|
it('handles multiple get methods reacting to same setTime change', () => {
|
|
246
246
|
component DateTest() {
|
|
247
247
|
let date = RippleDate(2025, 0, 1, 10, 30, 15);
|
|
248
|
-
let year = track(() => date.getFullYear());
|
|
249
|
-
let month = track(() => date.getMonth());
|
|
250
|
-
let day = track(() => date.getDate());
|
|
251
|
-
let hours = track(() => date.getHours());
|
|
248
|
+
let &[year] = track(() => date.getFullYear());
|
|
249
|
+
let &[month] = track(() => date.getMonth());
|
|
250
|
+
let &[day] = track(() => date.getDate());
|
|
251
|
+
let &[hours] = track(() => date.getHours());
|
|
252
252
|
|
|
253
253
|
<button onClick={() => date.setTime(new Date(2026, 5, 15, 14, 45, 30).getTime())}>
|
|
254
254
|
{'Change All'}
|
|
255
255
|
</button>
|
|
256
256
|
<div>
|
|
257
257
|
{'Year: '}
|
|
258
|
-
{
|
|
258
|
+
{year}
|
|
259
259
|
</div>
|
|
260
260
|
<div>
|
|
261
261
|
{'Month: '}
|
|
262
|
-
{
|
|
262
|
+
{month}
|
|
263
263
|
</div>
|
|
264
264
|
<div>
|
|
265
265
|
{'Day: '}
|
|
266
|
-
{
|
|
266
|
+
{day}
|
|
267
267
|
</div>
|
|
268
268
|
<div>
|
|
269
269
|
{'Hours: '}
|
|
270
|
-
{
|
|
270
|
+
{hours}
|
|
271
271
|
</div>
|
|
272
272
|
}
|
|
273
273
|
|
|
@@ -297,26 +297,26 @@ describe('RippleDate', () => {
|
|
|
297
297
|
let dateFromNumbers = RippleDate(2025, 0, 1);
|
|
298
298
|
let dateFromTimestamp = RippleDate(1735689600000);
|
|
299
299
|
|
|
300
|
-
let nowYear = track(() => dateNow.getFullYear());
|
|
301
|
-
let stringYear = track(() => dateFromString.getFullYear());
|
|
302
|
-
let numbersYear = track(() => dateFromNumbers.getFullYear());
|
|
303
|
-
let timestampYear = track(() => dateFromTimestamp.getFullYear());
|
|
300
|
+
let &[nowYear] = track(() => dateNow.getFullYear());
|
|
301
|
+
let &[stringYear] = track(() => dateFromString.getFullYear());
|
|
302
|
+
let &[numbersYear] = track(() => dateFromNumbers.getFullYear());
|
|
303
|
+
let &[timestampYear] = track(() => dateFromTimestamp.getFullYear());
|
|
304
304
|
|
|
305
305
|
<div>
|
|
306
306
|
{'Now: '}
|
|
307
|
-
{
|
|
307
|
+
{nowYear}
|
|
308
308
|
</div>
|
|
309
309
|
<div>
|
|
310
310
|
{'String: '}
|
|
311
|
-
{
|
|
311
|
+
{stringYear}
|
|
312
312
|
</div>
|
|
313
313
|
<div>
|
|
314
314
|
{'Numbers: '}
|
|
315
|
-
{
|
|
315
|
+
{numbersYear}
|
|
316
316
|
</div>
|
|
317
317
|
<div>
|
|
318
318
|
{'Timestamp: '}
|
|
319
|
-
{
|
|
319
|
+
{timestampYear}
|
|
320
320
|
</div>
|
|
321
321
|
}
|
|
322
322
|
|
|
@@ -342,17 +342,17 @@ describe('RippleDate', () => {
|
|
|
342
342
|
it('handles get methods with arguments non-memoized', () => {
|
|
343
343
|
component DateTest() {
|
|
344
344
|
let date = RippleDate();
|
|
345
|
-
let localeDateString = track(() => date.toLocaleDateString('en-US'));
|
|
346
|
-
let localeTimeString = track(() => date.toLocaleTimeString('en-US'));
|
|
345
|
+
let &[localeDateString] = track(() => date.toLocaleDateString('en-US'));
|
|
346
|
+
let &[localeTimeString] = track(() => date.toLocaleTimeString('en-US'));
|
|
347
347
|
|
|
348
348
|
<button onClick={() => date.setFullYear(date.getFullYear() + 1)}>{'Next Year'}</button>
|
|
349
349
|
<div>
|
|
350
350
|
{'Date: '}
|
|
351
|
-
{
|
|
351
|
+
{localeDateString}
|
|
352
352
|
</div>
|
|
353
353
|
<div>
|
|
354
354
|
{'Time: '}
|
|
355
|
-
{
|
|
355
|
+
{localeTimeString}
|
|
356
356
|
</div>
|
|
357
357
|
}
|
|
358
358
|
|