ripple 0.3.72 → 0.3.76
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 +116 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +4 -10
- package/src/runtime/dynamic-client.js +33 -0
- package/src/runtime/dynamic-server.js +80 -0
- package/src/runtime/index-client.js +5 -13
- package/src/runtime/index-server.js +2 -0
- package/src/runtime/internal/client/blocks.js +6 -27
- package/src/runtime/internal/client/composite.js +11 -6
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/render.js +5 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- package/src/runtime/internal/server/index.js +8 -1
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
- package/tests/client/array/array.copy-within.test.tsrx +19 -19
- package/tests/client/array/array.derived.test.tsrx +97 -109
- package/tests/client/array/array.iteration.test.tsrx +28 -28
- package/tests/client/array/array.mutations.test.tsrx +68 -68
- package/tests/client/array/array.static.test.tsrx +82 -92
- package/tests/client/array/array.to-methods.test.tsrx +15 -15
- package/tests/client/async-suspend.test.tsrx +180 -179
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
- package/tests/client/basic/basic.attributes.test.tsrx +273 -317
- package/tests/client/basic/basic.collections.test.tsrx +55 -61
- package/tests/client/basic/basic.components.test.tsrx +198 -220
- package/tests/client/basic/basic.errors.test.tsrx +70 -76
- package/tests/client/basic/basic.events.test.tsrx +80 -85
- package/tests/client/basic/basic.get-set.test.tsrx +54 -64
- package/tests/client/basic/basic.hmr.test.tsrx +15 -19
- package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
- package/tests/client/basic/basic.rendering.test.tsrx +273 -178
- package/tests/client/basic/basic.styling.test.tsrx +16 -14
- package/tests/client/basic/basic.utilities.test.tsrx +8 -10
- package/tests/client/boundaries.test.tsrx +18 -18
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
- package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
- package/tests/client/compiler/compiler.basic.test.tsrx +357 -288
- package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
- package/tests/client/composite/composite.dynamic-components.test.tsrx +62 -47
- package/tests/client/composite/composite.generics.test.tsrx +165 -167
- package/tests/client/composite/composite.props.test.tsrx +66 -74
- package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
- package/tests/client/composite/composite.render.test.tsrx +92 -101
- package/tests/client/computed-properties.test.tsrx +14 -18
- package/tests/client/context.test.tsrx +14 -18
- package/tests/client/css/global-additional-cases.test.tsrx +493 -439
- package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
- package/tests/client/css/global-at-rules.test.tsrx +71 -66
- package/tests/client/css/global-basic.test.tsrx +105 -98
- package/tests/client/css/global-classes-ids.test.tsrx +128 -114
- package/tests/client/css/global-combinators.test.tsrx +83 -78
- package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
- package/tests/client/css/global-edge-cases.test.tsrx +138 -120
- package/tests/client/css/global-keyframes.test.tsrx +108 -96
- package/tests/client/css/global-nested.test.tsrx +88 -78
- package/tests/client/css/global-pseudo.test.tsrx +104 -98
- package/tests/client/css/global-scoping.test.tsrx +145 -125
- package/tests/client/css/style-identifier.test.tsrx +65 -72
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +318 -299
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +74 -48
- package/tests/client/html.test.tsrx +37 -49
- package/tests/client/input-value.test.tsrx +1125 -1354
- package/tests/client/lazy-array.test.tsrx +10 -16
- package/tests/client/lazy-destructuring.test.tsrx +169 -221
- package/tests/client/map.test.tsrx +39 -41
- package/tests/client/media-query.test.tsrx +15 -19
- package/tests/client/object.test.tsrx +46 -56
- package/tests/client/portal.test.tsrx +31 -37
- package/tests/client/ref.test.tsrx +173 -193
- package/tests/client/return.test.tsrx +62 -37
- package/tests/client/set.test.tsrx +33 -33
- package/tests/client/svg.test.tsrx +197 -216
- package/tests/client/switch.test.tsrx +201 -191
- package/tests/client/track-async-hydration.test.tsrx +14 -18
- package/tests/client/tracked-index-access.test.tsrx +18 -28
- package/tests/client/try.test.tsrx +494 -619
- package/tests/client/tsx.test.tsrx +286 -292
- package/tests/client/typescript-generics.test.tsrx +121 -129
- package/tests/client/url/url.derived.test.tsrx +21 -25
- package/tests/client/url/url.parsing.test.tsrx +35 -35
- package/tests/client/url/url.partial-removal.test.tsrx +32 -32
- package/tests/client/url/url.reactivity.test.tsrx +68 -72
- package/tests/client/url/url.serialization.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
- package/tests/hydration/compiled/client/basic.js +390 -319
- package/tests/hydration/compiled/client/composite.js +52 -44
- package/tests/hydration/compiled/client/for.js +734 -604
- package/tests/hydration/compiled/client/head.js +183 -103
- package/tests/hydration/compiled/client/html.js +93 -86
- package/tests/hydration/compiled/client/if-children.js +95 -71
- package/tests/hydration/compiled/client/if.js +113 -89
- package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
- package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
- package/tests/hydration/compiled/client/reactivity.js +26 -24
- package/tests/hydration/compiled/client/return.js +8 -42
- package/tests/hydration/compiled/client/switch.js +208 -173
- package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
- package/tests/hydration/compiled/client/try.js +29 -21
- package/tests/hydration/compiled/server/basic.js +210 -221
- package/tests/hydration/compiled/server/composite.js +13 -14
- package/tests/hydration/compiled/server/for.js +427 -444
- package/tests/hydration/compiled/server/head.js +199 -189
- package/tests/hydration/compiled/server/html.js +33 -41
- package/tests/hydration/compiled/server/if-children.js +114 -117
- package/tests/hydration/compiled/server/if.js +77 -83
- package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
- package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
- package/tests/hydration/compiled/server/reactivity.js +24 -22
- package/tests/hydration/compiled/server/return.js +6 -18
- package/tests/hydration/compiled/server/switch.js +179 -176
- package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
- package/tests/hydration/compiled/server/try.js +31 -35
- package/tests/hydration/components/basic.tsrx +216 -258
- package/tests/hydration/components/composite.tsrx +32 -42
- package/tests/hydration/components/events.tsrx +81 -101
- package/tests/hydration/components/for.tsrx +270 -336
- package/tests/hydration/components/head.tsrx +43 -39
- package/tests/hydration/components/hmr.tsrx +16 -22
- package/tests/hydration/components/html-in-template.tsrx +15 -21
- package/tests/hydration/components/html.tsrx +442 -526
- package/tests/hydration/components/if-children.tsrx +107 -125
- package/tests/hydration/components/if.tsrx +68 -90
- package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
- package/tests/hydration/components/nested-control-flow.tsrx +202 -216
- package/tests/hydration/components/portal.tsrx +33 -41
- package/tests/hydration/components/reactivity.tsrx +26 -34
- package/tests/hydration/components/return.tsrx +4 -6
- package/tests/hydration/components/switch.tsrx +73 -78
- package/tests/hydration/components/track-async-serialization.tsrx +83 -93
- package/tests/hydration/components/try.tsrx +37 -51
- package/tests/hydration/switch.test.js +8 -8
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +117 -162
- package/tests/server/basic.components.test.tsrx +164 -194
- package/tests/server/basic.test.tsrx +299 -199
- package/tests/server/compiler.test.tsrx +142 -72
- package/tests/server/composite.props.test.tsrx +54 -58
- package/tests/server/composite.test.tsrx +165 -167
- package/tests/server/context.test.tsrx +13 -17
- package/tests/server/dynamic-elements.test.tsrx +147 -148
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +54 -31
- package/tests/server/html-nesting-validation.test.tsrx +16 -8
- package/tests/server/if.test.tsrx +49 -59
- package/tests/server/lazy-destructuring.test.tsrx +288 -366
- package/tests/server/return.test.tsrx +58 -36
- package/tests/server/streaming-ssr.test.tsrx +4 -4
- package/tests/server/style-identifier.test.tsrx +61 -69
- package/tests/server/switch.test.tsrx +89 -97
- package/tests/server/track-async-serialization.test.tsrx +85 -103
- package/tests/server/try.test.tsrx +275 -360
- package/tests/utils/ref-types.test.js +72 -0
- package/tests/utils/vite-plugin-config.test.js +41 -74
- package/types/index.d.ts +29 -4
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -59,16 +59,6 @@ export type BlockWithTryBoundaryAndCatch = Omit<BlockWithTryBoundary, 's'> & {
|
|
|
59
59
|
s: TryBoundaryState & { c: NonNullable<TryBoundaryState['c']> };
|
|
60
60
|
};
|
|
61
61
|
|
|
62
|
-
export type CompatApi = {
|
|
63
|
-
createRoot: () => void;
|
|
64
|
-
createComponent: (node: any, children_fn: () => any) => void;
|
|
65
|
-
jsx: (type: any, props: any) => any;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type CompatOptions = {
|
|
69
|
-
[key: string]: CompatApi;
|
|
70
|
-
};
|
|
71
|
-
|
|
72
62
|
export type RootBoundaryOptions = {
|
|
73
63
|
pending?: (anchor: Node, props: Record<string, never>, block: Block | null) => void;
|
|
74
64
|
catch?: (anchor: Node, props: { error: unknown; reset: () => void }, block: Block | null) => void;
|
|
@@ -1244,18 +1244,25 @@ function get_styles(styles) {
|
|
|
1244
1244
|
/**
|
|
1245
1245
|
* @param {Record<string, any>} attrs
|
|
1246
1246
|
* @param {string | undefined} css_hash
|
|
1247
|
+
* @param {string} [exclude_prop]
|
|
1247
1248
|
* @returns {string}
|
|
1248
1249
|
*/
|
|
1249
|
-
export function spread_attrs(attrs, css_hash) {
|
|
1250
|
+
export function spread_attrs(attrs, css_hash, exclude_prop) {
|
|
1250
1251
|
let attr_str = '';
|
|
1251
1252
|
let name;
|
|
1252
1253
|
|
|
1254
|
+
if (css_hash === undefined && Object.prototype.hasOwnProperty.call(attrs, '#class')) {
|
|
1255
|
+
css_hash = attrs['#class'];
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1253
1258
|
for (name in attrs) {
|
|
1254
1259
|
var value = attrs[name];
|
|
1255
1260
|
|
|
1256
1261
|
if (
|
|
1257
1262
|
name === 'children' ||
|
|
1258
1263
|
name === 'innerHTML' ||
|
|
1264
|
+
name === '#class' ||
|
|
1265
|
+
name === exclude_prop ||
|
|
1259
1266
|
typeof value === 'function' ||
|
|
1260
1267
|
is_tsrx_element(value)
|
|
1261
1268
|
)
|
|
@@ -2,48 +2,56 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`computed tracked properties > should update a property using assignment 1`] = `
|
|
4
4
|
<div>
|
|
5
|
+
<!---->
|
|
5
6
|
<div>
|
|
6
7
|
0
|
|
7
8
|
</div>
|
|
8
9
|
<button>
|
|
9
10
|
Increment
|
|
10
11
|
</button>
|
|
12
|
+
<!---->
|
|
11
13
|
|
|
12
14
|
</div>
|
|
13
15
|
`;
|
|
14
16
|
|
|
15
17
|
exports[`computed tracked properties > should update a property using assignment 2`] = `
|
|
16
18
|
<div>
|
|
19
|
+
<!---->
|
|
17
20
|
<div>
|
|
18
21
|
1
|
|
19
22
|
</div>
|
|
20
23
|
<button>
|
|
21
24
|
Increment
|
|
22
25
|
</button>
|
|
26
|
+
<!---->
|
|
23
27
|
|
|
24
28
|
</div>
|
|
25
29
|
`;
|
|
26
30
|
|
|
27
31
|
exports[`computed tracked properties > should update a property using update expressions 1`] = `
|
|
28
32
|
<div>
|
|
33
|
+
<!---->
|
|
29
34
|
<div>
|
|
30
35
|
0
|
|
31
36
|
</div>
|
|
32
37
|
<button>
|
|
33
38
|
Increment
|
|
34
39
|
</button>
|
|
40
|
+
<!---->
|
|
35
41
|
|
|
36
42
|
</div>
|
|
37
43
|
`;
|
|
38
44
|
|
|
39
45
|
exports[`computed tracked properties > should update a property using update expressions 2`] = `
|
|
40
46
|
<div>
|
|
47
|
+
<!---->
|
|
41
48
|
<div>
|
|
42
49
|
1
|
|
43
50
|
</div>
|
|
44
51
|
<button>
|
|
45
52
|
Increment
|
|
46
53
|
</button>
|
|
54
|
+
<!---->
|
|
47
55
|
|
|
48
56
|
</div>
|
|
49
57
|
`;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`for statements > correctly handles intermediate statements in for block 1`] = `
|
|
4
4
|
<div>
|
|
5
|
+
<!---->
|
|
5
6
|
<div>
|
|
6
7
|
<div>
|
|
7
8
|
<div>
|
|
@@ -32,12 +33,14 @@ exports[`for statements > correctly handles intermediate statements in for block
|
|
|
32
33
|
<button>
|
|
33
34
|
Add Item
|
|
34
35
|
</button>
|
|
36
|
+
<!---->
|
|
35
37
|
|
|
36
38
|
</div>
|
|
37
39
|
`;
|
|
38
40
|
|
|
39
41
|
exports[`for statements > correctly handles intermediate statements in for block 2`] = `
|
|
40
42
|
<div>
|
|
43
|
+
<!---->
|
|
41
44
|
<div>
|
|
42
45
|
<div>
|
|
43
46
|
<div>
|
|
@@ -76,12 +79,14 @@ exports[`for statements > correctly handles intermediate statements in for block
|
|
|
76
79
|
<button>
|
|
77
80
|
Add Item
|
|
78
81
|
</button>
|
|
82
|
+
<!---->
|
|
79
83
|
|
|
80
84
|
</div>
|
|
81
85
|
`;
|
|
82
86
|
|
|
83
87
|
exports[`for statements > correctly handles keyed for...of loops 1`] = `
|
|
84
88
|
<div>
|
|
89
|
+
<!---->
|
|
85
90
|
<!---->
|
|
86
91
|
<div>
|
|
87
92
|
0:Item 1
|
|
@@ -96,12 +101,14 @@ exports[`for statements > correctly handles keyed for...of loops 1`] = `
|
|
|
96
101
|
<button>
|
|
97
102
|
Reverse
|
|
98
103
|
</button>
|
|
104
|
+
<!---->
|
|
99
105
|
|
|
100
106
|
</div>
|
|
101
107
|
`;
|
|
102
108
|
|
|
103
109
|
exports[`for statements > correctly handles keyed for...of loops 2`] = `
|
|
104
110
|
<div>
|
|
111
|
+
<!---->
|
|
105
112
|
<!---->
|
|
106
113
|
<div>
|
|
107
114
|
0:Item 3
|
|
@@ -116,12 +123,14 @@ exports[`for statements > correctly handles keyed for...of loops 2`] = `
|
|
|
116
123
|
<button>
|
|
117
124
|
Reverse
|
|
118
125
|
</button>
|
|
126
|
+
<!---->
|
|
119
127
|
|
|
120
128
|
</div>
|
|
121
129
|
`;
|
|
122
130
|
|
|
123
131
|
exports[`for statements > correctly handles the index in a for...of loop 1`] = `
|
|
124
132
|
<div>
|
|
133
|
+
<!---->
|
|
125
134
|
<div>
|
|
126
135
|
<div>
|
|
127
136
|
0 : a
|
|
@@ -140,12 +149,14 @@ exports[`for statements > correctly handles the index in a for...of loop 1`] = `
|
|
|
140
149
|
<button>
|
|
141
150
|
Reverse
|
|
142
151
|
</button>
|
|
152
|
+
<!---->
|
|
143
153
|
|
|
144
154
|
</div>
|
|
145
155
|
`;
|
|
146
156
|
|
|
147
157
|
exports[`for statements > correctly handles the index in a for...of loop 2`] = `
|
|
148
158
|
<div>
|
|
159
|
+
<!---->
|
|
149
160
|
<div>
|
|
150
161
|
<div>
|
|
151
162
|
0 : a
|
|
@@ -167,12 +178,14 @@ exports[`for statements > correctly handles the index in a for...of loop 2`] = `
|
|
|
167
178
|
<button>
|
|
168
179
|
Reverse
|
|
169
180
|
</button>
|
|
181
|
+
<!---->
|
|
170
182
|
|
|
171
183
|
</div>
|
|
172
184
|
`;
|
|
173
185
|
|
|
174
186
|
exports[`for statements > correctly handles the index in a for...of loop 3`] = `
|
|
175
187
|
<div>
|
|
188
|
+
<!---->
|
|
176
189
|
<div>
|
|
177
190
|
<div>
|
|
178
191
|
0 : d
|
|
@@ -194,12 +207,14 @@ exports[`for statements > correctly handles the index in a for...of loop 3`] = `
|
|
|
194
207
|
<button>
|
|
195
208
|
Reverse
|
|
196
209
|
</button>
|
|
210
|
+
<!---->
|
|
197
211
|
|
|
198
212
|
</div>
|
|
199
213
|
`;
|
|
200
214
|
|
|
201
215
|
exports[`for statements > handles updating with new objects with same key 1`] = `
|
|
202
216
|
<div>
|
|
217
|
+
<!---->
|
|
203
218
|
<!---->
|
|
204
219
|
<div>
|
|
205
220
|
0:Item 1
|
|
@@ -214,12 +229,14 @@ exports[`for statements > handles updating with new objects with same key 1`] =
|
|
|
214
229
|
<button>
|
|
215
230
|
Reverse
|
|
216
231
|
</button>
|
|
232
|
+
<!---->
|
|
217
233
|
|
|
218
234
|
</div>
|
|
219
235
|
`;
|
|
220
236
|
|
|
221
237
|
exports[`for statements > handles updating with new objects with same key 2`] = `
|
|
222
238
|
<div>
|
|
239
|
+
<!---->
|
|
223
240
|
<!---->
|
|
224
241
|
<div>
|
|
225
242
|
0:Item 1!
|
|
@@ -234,12 +251,14 @@ exports[`for statements > handles updating with new objects with same key 2`] =
|
|
|
234
251
|
<button>
|
|
235
252
|
Reverse
|
|
236
253
|
</button>
|
|
254
|
+
<!---->
|
|
237
255
|
|
|
238
256
|
</div>
|
|
239
257
|
`;
|
|
240
258
|
|
|
241
259
|
exports[`for statements > renders a simple dynamic array 1`] = `
|
|
242
260
|
<div>
|
|
261
|
+
<!---->
|
|
243
262
|
<!---->
|
|
244
263
|
<div
|
|
245
264
|
class="Item 1"
|
|
@@ -260,12 +279,14 @@ exports[`for statements > renders a simple dynamic array 1`] = `
|
|
|
260
279
|
<button>
|
|
261
280
|
Add Item
|
|
262
281
|
</button>
|
|
282
|
+
<!---->
|
|
263
283
|
|
|
264
284
|
</div>
|
|
265
285
|
`;
|
|
266
286
|
|
|
267
287
|
exports[`for statements > renders a simple dynamic array 2`] = `
|
|
268
288
|
<div>
|
|
289
|
+
<!---->
|
|
269
290
|
<!---->
|
|
270
291
|
<div
|
|
271
292
|
class="Item 1"
|
|
@@ -291,6 +312,7 @@ exports[`for statements > renders a simple dynamic array 2`] = `
|
|
|
291
312
|
<button>
|
|
292
313
|
Add Item
|
|
293
314
|
</button>
|
|
315
|
+
<!---->
|
|
294
316
|
|
|
295
317
|
</div>
|
|
296
318
|
`;
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`Fragment innerHTML > renders dynamic innerHTML fragments 1`] = `
|
|
4
4
|
<div>
|
|
5
|
+
<!---->
|
|
5
6
|
<!---->
|
|
6
7
|
<div>
|
|
7
8
|
Test
|
|
@@ -10,12 +11,14 @@ exports[`Fragment innerHTML > renders dynamic innerHTML fragments 1`] = `
|
|
|
10
11
|
<button>
|
|
11
12
|
Update
|
|
12
13
|
</button>
|
|
14
|
+
<!---->
|
|
13
15
|
|
|
14
16
|
</div>
|
|
15
17
|
`;
|
|
16
18
|
|
|
17
19
|
exports[`Fragment innerHTML > renders dynamic innerHTML fragments 2`] = `
|
|
18
20
|
<div>
|
|
21
|
+
<!---->
|
|
19
22
|
<!---->
|
|
20
23
|
<div>
|
|
21
24
|
Updated
|
|
@@ -24,6 +27,7 @@ exports[`Fragment innerHTML > renders dynamic innerHTML fragments 2`] = `
|
|
|
24
27
|
<button>
|
|
25
28
|
Update
|
|
26
29
|
</button>
|
|
30
|
+
<!---->
|
|
27
31
|
|
|
28
32
|
</div>
|
|
29
33
|
`;
|
|
@@ -2,19 +2,19 @@ import { RippleArray, flushSync, track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('RippleArray copyWithin', () => {
|
|
4
4
|
it('handles copyWithin operation with reactivity', () => {
|
|
5
|
-
function ArrayTest() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
function ArrayTest() @{
|
|
6
|
+
let items = new RippleArray(1, 2, 3, 4, 5);
|
|
7
|
+
let &[firstItem] = track(() => items[0]);
|
|
8
|
+
let &[thirdItem] = track(() => items[2]);
|
|
9
|
+
let &[fourthItem] = track(() => items[3]);
|
|
10
|
+
<>
|
|
11
11
|
<button onClick={() => items.copyWithin(0, 3)}>{'copy end to start'}</button>
|
|
12
12
|
<button onClick={() => items.copyWithin(2, 0, 2)}>{'copy start to middle'}</button>
|
|
13
13
|
<pre>{JSON.stringify(items)}</pre>
|
|
14
14
|
<pre>{firstItem}</pre>
|
|
15
15
|
<pre>{thirdItem}</pre>
|
|
16
16
|
<pre>{fourthItem}</pre>
|
|
17
|
-
|
|
17
|
+
</>
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
render(ArrayTest);
|
|
@@ -48,16 +48,16 @@ describe('RippleArray copyWithin', () => {
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
it('handles copyWithin with negative indexes and reactivity', () => {
|
|
51
|
-
function ArrayTest() {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
51
|
+
function ArrayTest() @{
|
|
52
|
+
let items = new RippleArray(1, 2, 3, 4, 5);
|
|
53
|
+
let &[secondItem] = track(() => items[1]);
|
|
54
|
+
let &[thirdItem] = track(() => items[2]);
|
|
55
|
+
<>
|
|
56
56
|
<button onClick={() => items.copyWithin(-4, -2)}>{'copy with negative indexes'}</button>
|
|
57
57
|
<pre>{JSON.stringify(items)}</pre>
|
|
58
58
|
<pre>{secondItem}</pre>
|
|
59
59
|
<pre>{thirdItem}</pre>
|
|
60
|
-
|
|
60
|
+
</>
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
render(ArrayTest);
|
|
@@ -80,16 +80,16 @@ describe('RippleArray copyWithin', () => {
|
|
|
80
80
|
});
|
|
81
81
|
|
|
82
82
|
it('handles copyWithin with overlapping ranges', () => {
|
|
83
|
-
function ArrayTest() {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
83
|
+
function ArrayTest() @{
|
|
84
|
+
let items = new RippleArray(1, 2, 3, 4, 5);
|
|
85
|
+
let &[entries] = track(() => Array.from(items.entries()));
|
|
86
|
+
<>
|
|
87
87
|
<button onClick={() => items.copyWithin(2, 1, 4)}>{'copy with overlap'}</button>
|
|
88
88
|
<pre>{JSON.stringify(items)}</pre>
|
|
89
|
-
for (const [i, value] of entries) {
|
|
89
|
+
@for (const [i, value] of entries) {
|
|
90
90
|
<pre>{`items[${i}]: ${value}`}</pre>
|
|
91
91
|
}
|
|
92
|
-
|
|
92
|
+
</>
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
render(ArrayTest);
|