ripple 0.3.68 → 0.3.70
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 +57 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -2
- package/src/runtime/element.js +1 -1
- package/src/runtime/index-client.js +11 -11
- package/src/runtime/index-server.js +7 -4
- package/src/runtime/internal/client/bindings.js +1 -1
- package/src/runtime/internal/client/blocks.js +13 -4
- package/src/runtime/internal/client/component.js +55 -0
- package/src/runtime/internal/client/composite.js +4 -2
- package/src/runtime/internal/client/expression.js +65 -7
- package/src/runtime/internal/client/hmr.js +54 -43
- package/src/runtime/internal/client/index.js +5 -1
- package/src/runtime/internal/client/portal.js +70 -69
- package/src/runtime/internal/client/render.js +3 -0
- package/src/runtime/internal/server/index.js +92 -8
- package/tests/client/__snapshots__/html.test.tsrx.snap +3 -3
- package/tests/client/array/array.copy-within.test.tsrx +33 -31
- package/tests/client/array/array.derived.test.tsrx +186 -169
- package/tests/client/array/array.iteration.test.tsrx +40 -37
- package/tests/client/array/array.mutations.test.tsrx +113 -101
- package/tests/client/array/array.static.test.tsrx +119 -101
- package/tests/client/array/array.to-methods.test.tsrx +24 -21
- package/tests/client/async-suspend.test.tsrx +247 -246
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +0 -1
- package/tests/client/basic/basic.attributes.test.tsrx +428 -423
- package/tests/client/basic/basic.collections.test.tsrx +109 -102
- package/tests/client/basic/basic.components.test.tsrx +323 -205
- package/tests/client/basic/basic.errors.test.tsrx +91 -91
- package/tests/client/basic/basic.events.test.tsrx +114 -115
- package/tests/client/basic/basic.get-set.test.tsrx +97 -87
- package/tests/client/basic/basic.hmr.test.tsrx +19 -16
- package/tests/client/basic/basic.reactivity.test.tsrx +199 -191
- package/tests/client/basic/basic.rendering.test.tsrx +272 -182
- package/tests/client/basic/basic.styling.test.tsrx +23 -22
- package/tests/client/basic/basic.utilities.test.tsrx +10 -8
- package/tests/client/boundaries.test.tsrx +26 -26
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.rsrx.snap +5 -5
- package/tests/client/compiler/__snapshots__/compiler.assignments.test.tsrx.snap +5 -5
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -81
- package/tests/client/compiler/compiler.attributes.test.tsrx +15 -15
- package/tests/client/compiler/compiler.basic.test.tsrx +322 -314
- package/tests/client/compiler/compiler.regex.test.tsrx +44 -47
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +38 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +2 -2
- package/tests/client/composite/composite.dynamic-components.test.tsrx +47 -48
- package/tests/client/composite/composite.generics.test.tsrx +168 -192
- package/tests/client/composite/composite.props.test.tsrx +97 -81
- package/tests/client/composite/composite.reactivity.test.tsrx +177 -147
- package/tests/client/composite/composite.render.test.tsrx +122 -105
- package/tests/client/computed-properties.test.tsrx +28 -28
- package/tests/client/context.test.tsrx +21 -21
- package/tests/client/css/global-additional-cases.test.tsrx +58 -58
- package/tests/client/css/global-advanced-selectors.test.tsrx +16 -16
- package/tests/client/css/global-at-rules.test.tsrx +10 -10
- package/tests/client/css/global-basic.test.tsrx +14 -14
- package/tests/client/css/global-classes-ids.test.tsrx +14 -14
- package/tests/client/css/global-combinators.test.tsrx +10 -10
- package/tests/client/css/global-complex-nesting.test.tsrx +14 -14
- package/tests/client/css/global-edge-cases.test.tsrx +18 -18
- package/tests/client/css/global-keyframes.test.tsrx +12 -12
- package/tests/client/css/global-nested.test.tsrx +10 -10
- package/tests/client/css/global-pseudo.test.tsrx +12 -12
- package/tests/client/css/global-scoping.test.tsrx +20 -20
- package/tests/client/css/style-identifier.test.tsrx +126 -259
- package/tests/client/date.test.tsrx +146 -133
- package/tests/client/dynamic-elements.test.tsrx +398 -365
- package/tests/client/events.test.tsrx +292 -290
- package/tests/client/for.test.tsrx +156 -153
- package/tests/client/head.test.tsrx +105 -96
- package/tests/client/html.test.tsrx +122 -26
- package/tests/client/input-value.test.tsrx +1361 -1314
- package/tests/client/lazy-array.test.tsrx +16 -13
- package/tests/client/lazy-destructuring.test.tsrx +257 -213
- package/tests/client/map.test.tsrx +65 -60
- package/tests/client/media-query.test.tsrx +22 -20
- package/tests/client/object.test.tsrx +87 -81
- package/tests/client/portal.test.tsrx +57 -51
- package/tests/client/ref.test.tsrx +233 -202
- package/tests/client/return.test.tsrx +71 -2560
- package/tests/client/set.test.tsrx +54 -45
- package/tests/client/svg.test.tsrx +216 -186
- package/tests/client/switch.test.tsrx +194 -193
- package/tests/client/track-async-hydration.test.tsrx +18 -14
- package/tests/client/tracked-index-access.test.tsrx +28 -18
- package/tests/client/try.test.tsrx +675 -548
- package/tests/client/tsx.test.tsrx +373 -311
- package/tests/client/typescript-generics.test.tsrx +145 -145
- package/tests/client/url/url.derived.test.tsrx +33 -28
- package/tests/client/url/url.parsing.test.tsrx +61 -51
- package/tests/client/url/url.partial-removal.test.tsrx +56 -48
- package/tests/client/url/url.reactivity.test.tsrx +142 -125
- package/tests/client/url/url.serialization.test.tsrx +13 -11
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +34 -29
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +25 -21
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +50 -45
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +111 -99
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +49 -43
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +14 -12
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +16 -14
- package/tests/hydration/basic.test.js +3 -3
- package/tests/hydration/compiled/client/basic.js +586 -651
- package/tests/hydration/compiled/client/composite.js +79 -104
- package/tests/hydration/compiled/client/events.js +140 -148
- package/tests/hydration/compiled/client/for.js +1005 -1018
- package/tests/hydration/compiled/client/head.js +124 -134
- package/tests/hydration/compiled/client/hmr.js +41 -48
- package/tests/hydration/compiled/client/html-in-template.js +38 -41
- package/tests/hydration/compiled/client/html.js +970 -1314
- package/tests/hydration/compiled/client/if-children.js +234 -249
- package/tests/hydration/compiled/client/if.js +182 -189
- package/tests/hydration/compiled/client/mixed-control-flow.js +347 -303
- package/tests/hydration/compiled/client/nested-control-flow.js +1084 -832
- package/tests/hydration/compiled/client/portal.js +65 -85
- package/tests/hydration/compiled/client/reactivity.js +84 -90
- package/tests/hydration/compiled/client/return.js +38 -1939
- package/tests/hydration/compiled/client/switch.js +218 -224
- package/tests/hydration/compiled/client/track-async-serialization.js +250 -259
- package/tests/hydration/compiled/client/try.js +123 -132
- package/tests/hydration/compiled/server/basic.js +773 -831
- package/tests/hydration/compiled/server/composite.js +166 -191
- package/tests/hydration/compiled/server/events.js +170 -184
- package/tests/hydration/compiled/server/for.js +851 -909
- package/tests/hydration/compiled/server/head.js +206 -216
- package/tests/hydration/compiled/server/hmr.js +64 -72
- package/tests/hydration/compiled/server/html-in-template.js +42 -76
- package/tests/hydration/compiled/server/html.js +1362 -1667
- package/tests/hydration/compiled/server/if-children.js +419 -445
- package/tests/hydration/compiled/server/if.js +194 -208
- package/tests/hydration/compiled/server/mixed-control-flow.js +249 -257
- package/tests/hydration/compiled/server/nested-control-flow.js +491 -515
- package/tests/hydration/compiled/server/portal.js +152 -160
- package/tests/hydration/compiled/server/reactivity.js +94 -106
- package/tests/hydration/compiled/server/return.js +28 -2172
- package/tests/hydration/compiled/server/switch.js +274 -286
- package/tests/hydration/compiled/server/track-async-serialization.js +340 -358
- package/tests/hydration/compiled/server/try.js +167 -185
- package/tests/hydration/components/basic.tsrx +320 -272
- package/tests/hydration/components/composite.tsrx +44 -32
- package/tests/hydration/components/events.tsrx +101 -91
- package/tests/hydration/components/for.tsrx +510 -452
- package/tests/hydration/components/head.tsrx +87 -80
- package/tests/hydration/components/hmr.tsrx +22 -17
- package/tests/hydration/components/html-in-template.tsrx +22 -17
- package/tests/hydration/components/html.tsrx +525 -443
- package/tests/hydration/components/if-children.tsrx +158 -148
- package/tests/hydration/components/if.tsrx +109 -95
- package/tests/hydration/components/mixed-control-flow.tsrx +100 -96
- package/tests/hydration/components/nested-control-flow.tsrx +215 -203
- package/tests/hydration/components/portal.tsrx +41 -34
- package/tests/hydration/components/reactivity.tsrx +37 -27
- package/tests/hydration/components/return.tsrx +12 -556
- package/tests/hydration/components/switch.tsrx +120 -114
- package/tests/hydration/components/track-async-serialization.tsrx +107 -91
- package/tests/hydration/components/try.tsrx +55 -40
- package/tests/hydration/html.test.js +4 -4
- package/tests/hydration/return.test.js +13 -532
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +264 -195
- package/tests/server/basic.components.test.tsrx +296 -169
- package/tests/server/basic.test.tsrx +300 -198
- package/tests/server/compiler.test.tsrx +62 -60
- package/tests/server/composite.props.test.tsrx +77 -63
- package/tests/server/composite.test.tsrx +168 -192
- package/tests/server/context.test.tsrx +18 -12
- package/tests/server/dynamic-elements.test.tsrx +197 -180
- package/tests/server/for.test.tsrx +85 -78
- package/tests/server/head.test.tsrx +50 -43
- package/tests/server/html-nesting-validation.test.tsrx +8 -8
- package/tests/server/if.test.tsrx +57 -51
- package/tests/server/lazy-destructuring.test.tsrx +366 -294
- package/tests/server/return.test.tsrx +76 -1355
- package/tests/server/streaming-ssr.test.tsrx +4 -75
- package/tests/server/style-identifier.test.tsrx +169 -131
- package/tests/server/switch.test.tsrx +91 -85
- package/tests/server/track-async-serialization.test.tsrx +105 -85
- package/tests/server/try.test.tsrx +374 -280
- package/tests/utils/compiler-compat-config.test.js +2 -2
- package/tests/utils/runtime-imports.test.js +10 -0
- package/types/index.d.ts +8 -0
- package/tests/client/__snapshots__/html.test.rsrx.snap +0 -40
|
@@ -105,14 +105,14 @@ describe('use value()', () => {
|
|
|
105
105
|
it('should update value on input', () => {
|
|
106
106
|
const logs: string[] = [];
|
|
107
107
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
108
|
+
function App() {
|
|
109
|
+
return <>
|
|
110
|
+
const text = track('');
|
|
111
|
+
effect(() => {
|
|
112
|
+
logs.push('text changed', text.value);
|
|
113
|
+
});
|
|
114
|
+
<input type="text" ref={bindValue(text)} />
|
|
115
|
+
</>;
|
|
116
116
|
}
|
|
117
117
|
render(App);
|
|
118
118
|
flushSync();
|
|
@@ -128,14 +128,14 @@ describe('use value()', () => {
|
|
|
128
128
|
it('should update value on input with getter and setter', () => {
|
|
129
129
|
const logs: string[] = [];
|
|
130
130
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
131
|
+
function App() {
|
|
132
|
+
return <>
|
|
133
|
+
const text = new RippleObject({ value: '' });
|
|
134
|
+
effect(() => {
|
|
135
|
+
logs.push('text changed', text.value);
|
|
136
|
+
});
|
|
137
|
+
<input type="text" ref={bindValue(() => text.value, (v) => (text.value = v))} />
|
|
138
|
+
</>;
|
|
139
139
|
}
|
|
140
140
|
render(App);
|
|
141
141
|
flushSync();
|
|
@@ -151,14 +151,14 @@ describe('use value()', () => {
|
|
|
151
151
|
it('should update value on input with a predefined value', () => {
|
|
152
152
|
const logs: string[] = [];
|
|
153
153
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
154
|
+
function App() {
|
|
155
|
+
return <>
|
|
156
|
+
const text = track('foo');
|
|
157
|
+
effect(() => {
|
|
158
|
+
logs.push('text changed', text.value);
|
|
159
|
+
});
|
|
160
|
+
<input type="text" ref={bindValue(text)} />
|
|
161
|
+
</>;
|
|
162
162
|
}
|
|
163
163
|
render(App);
|
|
164
164
|
flushSync();
|
|
@@ -175,13 +175,14 @@ describe('use value()', () => {
|
|
|
175
175
|
it('should update value on input with a predefined value and with a getter and setter', () => {
|
|
176
176
|
const logs: string[] = [];
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
178
|
+
function App() {
|
|
179
|
+
return <>
|
|
180
|
+
const text = new RippleObject({ value: 'foo' });
|
|
181
|
+
effect(() => {
|
|
182
|
+
logs.push('text changed', text.value);
|
|
183
|
+
});
|
|
184
|
+
<input type="text" ref={bindValue(() => text.value, (v) => (text.value = v))} />
|
|
185
|
+
</>;
|
|
185
186
|
}
|
|
186
187
|
render(App);
|
|
187
188
|
flushSync();
|
|
@@ -196,13 +197,14 @@ describe('use value()', () => {
|
|
|
196
197
|
});
|
|
197
198
|
|
|
198
199
|
it('should update text input element when tracked value changes', () => {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
200
|
+
function App() {
|
|
201
|
+
return <>
|
|
202
|
+
const text = track('initial');
|
|
203
|
+
<div>
|
|
204
|
+
<input type="text" ref={bindValue(text)} />
|
|
205
|
+
<button onClick={() => (text.value = 'updated')}>{'Update'}</button>
|
|
206
|
+
</div>
|
|
207
|
+
</>;
|
|
206
208
|
}
|
|
207
209
|
render(App);
|
|
208
210
|
flushSync();
|
|
@@ -219,13 +221,14 @@ describe('use value()', () => {
|
|
|
219
221
|
});
|
|
220
222
|
|
|
221
223
|
it('should update text input element when tracked value changes with a getter and setter', () => {
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
224
|
+
function App() {
|
|
225
|
+
return <>
|
|
226
|
+
const text = new RippleObject({ value: 'initial' });
|
|
227
|
+
<div>
|
|
228
|
+
<input type="text" ref={bindValue(() => text.value, (v) => (text.value = v))} />
|
|
229
|
+
<button onClick={() => (text.value = 'updated')}>{'Update'}</button>
|
|
230
|
+
</div>
|
|
231
|
+
</>;
|
|
229
232
|
}
|
|
230
233
|
render(App);
|
|
231
234
|
flushSync();
|
|
@@ -244,14 +247,14 @@ describe('use value()', () => {
|
|
|
244
247
|
it('should update checked on input', () => {
|
|
245
248
|
const logs: (string | boolean)[] = [];
|
|
246
249
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
250
|
+
function App() {
|
|
251
|
+
return <>
|
|
252
|
+
const value = track(false);
|
|
253
|
+
effect(() => {
|
|
254
|
+
logs.push('checked changed', value.value);
|
|
255
|
+
});
|
|
256
|
+
<input type="checkbox" ref={bindChecked(value)} />
|
|
257
|
+
</>;
|
|
255
258
|
}
|
|
256
259
|
render(App);
|
|
257
260
|
flushSync();
|
|
@@ -268,13 +271,17 @@ describe('use value()', () => {
|
|
|
268
271
|
it('should update checked on input with a getter and setter', () => {
|
|
269
272
|
const logs: (string | boolean)[] = [];
|
|
270
273
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
274
|
+
function App() {
|
|
275
|
+
return <>
|
|
276
|
+
const obj = new RippleObject({ value: false });
|
|
277
|
+
effect(() => {
|
|
278
|
+
logs.push('checked changed', obj.value);
|
|
279
|
+
});
|
|
280
|
+
<input
|
|
281
|
+
type="checkbox"
|
|
282
|
+
ref={bindChecked(() => obj.value, (v: boolean) => (obj.value = v))}
|
|
283
|
+
/>
|
|
284
|
+
</>;
|
|
278
285
|
}
|
|
279
286
|
render(App);
|
|
280
287
|
flushSync();
|
|
@@ -289,13 +296,14 @@ describe('use value()', () => {
|
|
|
289
296
|
});
|
|
290
297
|
|
|
291
298
|
it('should update checkbox element when tracked value changes', () => {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
+
function App() {
|
|
300
|
+
return <>
|
|
301
|
+
const value = track(false);
|
|
302
|
+
<div>
|
|
303
|
+
<input type="checkbox" ref={bindChecked(value)} />
|
|
304
|
+
<button onClick={() => (value.value = true)}>{'Check'}</button>
|
|
305
|
+
</div>
|
|
306
|
+
</>;
|
|
299
307
|
}
|
|
300
308
|
render(App);
|
|
301
309
|
flushSync();
|
|
@@ -312,16 +320,17 @@ describe('use value()', () => {
|
|
|
312
320
|
});
|
|
313
321
|
|
|
314
322
|
it('should update checkbox element when tracked value changes with a getter and setter', () => {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
323
|
+
function App() {
|
|
324
|
+
return <>
|
|
325
|
+
const obj = new RippleObject({ value: false });
|
|
326
|
+
<div>
|
|
327
|
+
<input
|
|
328
|
+
type="checkbox"
|
|
329
|
+
ref={bindChecked(() => obj.value, (v: boolean) => (obj.value = v))}
|
|
330
|
+
/>
|
|
331
|
+
<button onClick={() => (obj.value = true)}>{'Check'}</button>
|
|
332
|
+
</div>
|
|
333
|
+
</>;
|
|
325
334
|
}
|
|
326
335
|
render(App);
|
|
327
336
|
flushSync();
|
|
@@ -340,14 +349,14 @@ describe('use value()', () => {
|
|
|
340
349
|
it('should update indeterminate on input', () => {
|
|
341
350
|
const logs: (string | boolean)[] = [];
|
|
342
351
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
352
|
+
function App() {
|
|
353
|
+
return <>
|
|
354
|
+
const value = track(false);
|
|
355
|
+
effect(() => {
|
|
356
|
+
logs.push('indeterminate changed', value.value);
|
|
357
|
+
});
|
|
358
|
+
<input type="checkbox" ref={bindIndeterminate(value)} />
|
|
359
|
+
</>;
|
|
351
360
|
}
|
|
352
361
|
render(App);
|
|
353
362
|
flushSync();
|
|
@@ -366,17 +375,17 @@ describe('use value()', () => {
|
|
|
366
375
|
it('should update indeterminate on input with a getter and setter', () => {
|
|
367
376
|
const logs: (string | boolean)[] = [];
|
|
368
377
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
function App() {
|
|
379
|
+
return <>
|
|
380
|
+
const obj = new RippleObject({ value: false });
|
|
381
|
+
effect(() => {
|
|
382
|
+
logs.push('indeterminate changed', obj.value);
|
|
383
|
+
});
|
|
384
|
+
<input
|
|
385
|
+
type="checkbox"
|
|
386
|
+
ref={bindIndeterminate(() => obj.value, (v: boolean) => (obj.value = v))}
|
|
387
|
+
/>
|
|
388
|
+
</>;
|
|
380
389
|
}
|
|
381
390
|
render(App);
|
|
382
391
|
flushSync();
|
|
@@ -393,13 +402,14 @@ describe('use value()', () => {
|
|
|
393
402
|
});
|
|
394
403
|
|
|
395
404
|
it('should update checkbox indeterminate element when tracked value changes', () => {
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
405
|
+
function App() {
|
|
406
|
+
return <>
|
|
407
|
+
const value = track(false);
|
|
408
|
+
<div>
|
|
409
|
+
<input type="checkbox" ref={bindIndeterminate(value)} />
|
|
410
|
+
<button onClick={() => (value.value = true)}>{'Set Indeterminate'}</button>
|
|
411
|
+
</div>
|
|
412
|
+
</>;
|
|
403
413
|
}
|
|
404
414
|
render(App);
|
|
405
415
|
flushSync();
|
|
@@ -418,16 +428,17 @@ describe('use value()', () => {
|
|
|
418
428
|
it(
|
|
419
429
|
'should update checkbox indeterminate element when tracked value changes with a getter and setter',
|
|
420
430
|
() => {
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
+
function App() {
|
|
432
|
+
return <>
|
|
433
|
+
const obj = new RippleObject({ value: false });
|
|
434
|
+
<div>
|
|
435
|
+
<input
|
|
436
|
+
type="checkbox"
|
|
437
|
+
ref={bindIndeterminate(() => obj.value, (v: boolean) => (obj.value = v))}
|
|
438
|
+
/>
|
|
439
|
+
<button onClick={() => (obj.value = true)}>{'Set Indeterminate'}</button>
|
|
440
|
+
</div>
|
|
441
|
+
</>;
|
|
431
442
|
}
|
|
432
443
|
render(App);
|
|
433
444
|
flushSync();
|
|
@@ -447,18 +458,18 @@ describe('use value()', () => {
|
|
|
447
458
|
it('should update select value on change', () => {
|
|
448
459
|
const logs: string[] = [];
|
|
449
460
|
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
461
|
+
function App() {
|
|
462
|
+
return <>
|
|
463
|
+
const select = track('2');
|
|
464
|
+
effect(() => {
|
|
465
|
+
logs.push('select changed', select.value);
|
|
466
|
+
});
|
|
467
|
+
<select ref={bindValue(select)}>
|
|
468
|
+
<option value="1">{'One'}</option>
|
|
469
|
+
<option value="2">{'Two'}</option>
|
|
470
|
+
<option value="3">{'Three'}</option>
|
|
471
|
+
</select>
|
|
472
|
+
</>;
|
|
462
473
|
}
|
|
463
474
|
|
|
464
475
|
render(App);
|
|
@@ -476,17 +487,18 @@ describe('use value()', () => {
|
|
|
476
487
|
it('should update select value on change with a getter and setter', () => {
|
|
477
488
|
const logs: string[] = [];
|
|
478
489
|
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
+
function App() {
|
|
491
|
+
return <>
|
|
492
|
+
const select = new RippleObject({ value: '2' });
|
|
493
|
+
effect(() => {
|
|
494
|
+
logs.push('select changed', select.value);
|
|
495
|
+
});
|
|
496
|
+
<select ref={bindValue(() => select.value, (v) => (select.value = v))}>
|
|
497
|
+
<option value="1">{'One'}</option>
|
|
498
|
+
<option value="2">{'Two'}</option>
|
|
499
|
+
<option value="3">{'Three'}</option>
|
|
500
|
+
</select>
|
|
501
|
+
</>;
|
|
490
502
|
}
|
|
491
503
|
|
|
492
504
|
render(App);
|
|
@@ -502,17 +514,18 @@ describe('use value()', () => {
|
|
|
502
514
|
});
|
|
503
515
|
|
|
504
516
|
it('should update select element when tracked value changes', () => {
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
517
|
+
function App() {
|
|
518
|
+
return <>
|
|
519
|
+
const select = track('1');
|
|
520
|
+
<div>
|
|
521
|
+
<select ref={bindValue(select)}>
|
|
522
|
+
<option value="1">{'One'}</option>
|
|
523
|
+
<option value="2">{'Two'}</option>
|
|
524
|
+
<option value="3">{'Three'}</option>
|
|
525
|
+
</select>
|
|
526
|
+
<button onClick={() => (select.value = '3')}>{'Update'}</button>
|
|
527
|
+
</div>
|
|
528
|
+
</>;
|
|
516
529
|
}
|
|
517
530
|
|
|
518
531
|
render(App);
|
|
@@ -530,17 +543,18 @@ describe('use value()', () => {
|
|
|
530
543
|
});
|
|
531
544
|
|
|
532
545
|
it('should update select element when tracked value changes with a getter and setter', () => {
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
546
|
+
function App() {
|
|
547
|
+
return <>
|
|
548
|
+
const select = new RippleObject({ value: '1' });
|
|
549
|
+
<div>
|
|
550
|
+
<select ref={bindValue(() => select.value, (v) => (select.value = v))}>
|
|
551
|
+
<option value="1">{'One'}</option>
|
|
552
|
+
<option value="2">{'Two'}</option>
|
|
553
|
+
<option value="3">{'Three'}</option>
|
|
554
|
+
</select>
|
|
555
|
+
<button onClick={() => (select.value = '3')}>{'Update'}</button>
|
|
556
|
+
</div>
|
|
557
|
+
</>;
|
|
544
558
|
}
|
|
545
559
|
|
|
546
560
|
render(App);
|
|
@@ -560,18 +574,18 @@ describe('use value()', () => {
|
|
|
560
574
|
it('should bind checkbox group', () => {
|
|
561
575
|
const logs: string[] = [];
|
|
562
576
|
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
577
|
+
function App() {
|
|
578
|
+
return <>
|
|
579
|
+
const selected = track(['b']);
|
|
580
|
+
effect(() => {
|
|
581
|
+
logs.push('selected changed', JSON.stringify(selected.value));
|
|
582
|
+
});
|
|
583
|
+
<div>
|
|
584
|
+
<input type="checkbox" value="a" ref={bindGroup(selected)} />
|
|
585
|
+
<input type="checkbox" value="b" ref={bindGroup(selected)} />
|
|
586
|
+
<input type="checkbox" value="c" ref={bindGroup(selected)} />
|
|
587
|
+
</div>
|
|
588
|
+
</>;
|
|
575
589
|
}
|
|
576
590
|
|
|
577
591
|
render(App);
|
|
@@ -608,30 +622,30 @@ describe('use value()', () => {
|
|
|
608
622
|
it('should bind checkbox group with a getter and setter', () => {
|
|
609
623
|
const logs: string[] = [];
|
|
610
624
|
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
625
|
+
function App() {
|
|
626
|
+
return <>
|
|
627
|
+
const obj = new RippleObject({ selected: ['b'] });
|
|
628
|
+
effect(() => {
|
|
629
|
+
logs.push('selected changed', JSON.stringify(obj.selected));
|
|
630
|
+
});
|
|
631
|
+
<div>
|
|
632
|
+
<input
|
|
633
|
+
type="checkbox"
|
|
634
|
+
value="a"
|
|
635
|
+
ref={bindGroup(() => obj.selected, (v: string[]) => (obj.selected = v))}
|
|
636
|
+
/>
|
|
637
|
+
<input
|
|
638
|
+
type="checkbox"
|
|
639
|
+
value="b"
|
|
640
|
+
ref={bindGroup(() => obj.selected, (v: string[]) => (obj.selected = v))}
|
|
641
|
+
/>
|
|
642
|
+
<input
|
|
643
|
+
type="checkbox"
|
|
644
|
+
value="c"
|
|
645
|
+
ref={bindGroup(() => obj.selected, (v: string[]) => (obj.selected = v))}
|
|
646
|
+
/>
|
|
647
|
+
</div>
|
|
648
|
+
</>;
|
|
635
649
|
}
|
|
636
650
|
|
|
637
651
|
render(App);
|
|
@@ -668,18 +682,18 @@ describe('use value()', () => {
|
|
|
668
682
|
it('should bind radio group', () => {
|
|
669
683
|
const logs: string[] = [];
|
|
670
684
|
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
685
|
+
function App() {
|
|
686
|
+
return <>
|
|
687
|
+
const selected = track('b');
|
|
688
|
+
effect(() => {
|
|
689
|
+
logs.push('selected changed', selected.value);
|
|
690
|
+
});
|
|
691
|
+
<div>
|
|
692
|
+
<input type="radio" name="test" value="a" ref={bindGroup(selected)} />
|
|
693
|
+
<input type="radio" name="test" value="b" ref={bindGroup(selected)} />
|
|
694
|
+
<input type="radio" name="test" value="c" ref={bindGroup(selected)} />
|
|
695
|
+
</div>
|
|
696
|
+
</>;
|
|
683
697
|
}
|
|
684
698
|
|
|
685
699
|
render(App);
|
|
@@ -715,33 +729,33 @@ describe('use value()', () => {
|
|
|
715
729
|
it('should bind radio group with a getter and setter', () => {
|
|
716
730
|
const logs: string[] = [];
|
|
717
731
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
732
|
+
function App() {
|
|
733
|
+
return <>
|
|
734
|
+
const selected = new RippleObject({ value: 'b' });
|
|
735
|
+
effect(() => {
|
|
736
|
+
logs.push('selected changed', selected.value);
|
|
737
|
+
});
|
|
738
|
+
<div>
|
|
739
|
+
<input
|
|
740
|
+
type="radio"
|
|
741
|
+
name="test"
|
|
742
|
+
value="a"
|
|
743
|
+
ref={bindGroup(() => selected.value, (v: string) => (selected.value = v))}
|
|
744
|
+
/>
|
|
745
|
+
<input
|
|
746
|
+
type="radio"
|
|
747
|
+
name="test"
|
|
748
|
+
value="b"
|
|
749
|
+
ref={bindGroup(() => selected.value, (v: string) => (selected.value = v))}
|
|
750
|
+
/>
|
|
751
|
+
<input
|
|
752
|
+
type="radio"
|
|
753
|
+
name="test"
|
|
754
|
+
value="c"
|
|
755
|
+
ref={bindGroup(() => selected.value, (v: string) => (selected.value = v))}
|
|
756
|
+
/>
|
|
757
|
+
</div>
|
|
758
|
+
</>;
|
|
745
759
|
}
|
|
746
760
|
|
|
747
761
|
render(App);
|
|
@@ -775,15 +789,16 @@ describe('use value()', () => {
|
|
|
775
789
|
});
|
|
776
790
|
|
|
777
791
|
it('should update checkbox group from tracked value change', () => {
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
792
|
+
function App() {
|
|
793
|
+
return <>
|
|
794
|
+
const selected = track(['a']);
|
|
795
|
+
<div>
|
|
796
|
+
<input type="checkbox" value="a" ref={bindGroup(selected)} />
|
|
797
|
+
<input type="checkbox" value="b" ref={bindGroup(selected)} />
|
|
798
|
+
<input type="checkbox" value="c" ref={bindGroup(selected)} />
|
|
799
|
+
<button onClick={() => (selected.value = ['b', 'c'])}>{'Update'}</button>
|
|
800
|
+
</div>
|
|
801
|
+
</>;
|
|
787
802
|
}
|
|
788
803
|
|
|
789
804
|
render(App);
|
|
@@ -805,27 +820,28 @@ describe('use value()', () => {
|
|
|
805
820
|
});
|
|
806
821
|
|
|
807
822
|
it('should update checkbox group from tracked value change with a getter and setter', () => {
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
823
|
+
function App() {
|
|
824
|
+
return <>
|
|
825
|
+
const selected = new RippleObject({ value: ['a'] });
|
|
826
|
+
<div>
|
|
827
|
+
<input
|
|
828
|
+
type="checkbox"
|
|
829
|
+
value="a"
|
|
830
|
+
ref={bindGroup(() => selected.value, (v: string[]) => (selected.value = v))}
|
|
831
|
+
/>
|
|
832
|
+
<input
|
|
833
|
+
type="checkbox"
|
|
834
|
+
value="b"
|
|
835
|
+
ref={bindGroup(() => selected.value, (v: string[]) => (selected.value = v))}
|
|
836
|
+
/>
|
|
837
|
+
<input
|
|
838
|
+
type="checkbox"
|
|
839
|
+
value="c"
|
|
840
|
+
ref={bindGroup(() => selected.value, (v: string[]) => (selected.value = v))}
|
|
841
|
+
/>
|
|
842
|
+
<button onClick={() => (selected.value = ['b', 'c'])}>{'Update'}</button>
|
|
843
|
+
</div>
|
|
844
|
+
</>;
|
|
829
845
|
}
|
|
830
846
|
|
|
831
847
|
render(App);
|
|
@@ -847,15 +863,16 @@ describe('use value()', () => {
|
|
|
847
863
|
});
|
|
848
864
|
|
|
849
865
|
it('should update radio group from tracked value change', () => {
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
866
|
+
function App() {
|
|
867
|
+
return <>
|
|
868
|
+
const selected = track('a');
|
|
869
|
+
<div>
|
|
870
|
+
<input type="radio" name="test" value="a" ref={bindGroup(selected)} />
|
|
871
|
+
<input type="radio" name="test" value="b" ref={bindGroup(selected)} />
|
|
872
|
+
<input type="radio" name="test" value="c" ref={bindGroup(selected)} />
|
|
873
|
+
<button onClick={() => (selected.value = 'c')}>{'Update'}</button>
|
|
874
|
+
</div>
|
|
875
|
+
</>;
|
|
859
876
|
}
|
|
860
877
|
|
|
861
878
|
render(App);
|
|
@@ -877,30 +894,31 @@ describe('use value()', () => {
|
|
|
877
894
|
});
|
|
878
895
|
|
|
879
896
|
it('should update radio group from tracked value change with a getter and setter', () => {
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
897
|
+
function App() {
|
|
898
|
+
return <>
|
|
899
|
+
const selected = new RippleObject({ value: 'a' });
|
|
900
|
+
<div>
|
|
901
|
+
<input
|
|
902
|
+
type="radio"
|
|
903
|
+
name="test"
|
|
904
|
+
value="a"
|
|
905
|
+
ref={bindGroup(() => selected.value, (v: string) => (selected.value = v))}
|
|
906
|
+
/>
|
|
907
|
+
<input
|
|
908
|
+
type="radio"
|
|
909
|
+
name="test"
|
|
910
|
+
value="b"
|
|
911
|
+
ref={bindGroup(() => selected.value, (v: string) => (selected.value = v))}
|
|
912
|
+
/>
|
|
913
|
+
<input
|
|
914
|
+
type="radio"
|
|
915
|
+
name="test"
|
|
916
|
+
value="c"
|
|
917
|
+
ref={bindGroup(() => selected.value, (v: string) => (selected.value = v))}
|
|
918
|
+
/>
|
|
919
|
+
<button onClick={() => (selected.value = 'c')}>{'Update'}</button>
|
|
920
|
+
</div>
|
|
921
|
+
</>;
|
|
904
922
|
}
|
|
905
923
|
|
|
906
924
|
render(App);
|
|
@@ -922,13 +940,14 @@ describe('use value()', () => {
|
|
|
922
940
|
});
|
|
923
941
|
|
|
924
942
|
it('should handle checkbox group with initial empty array', () => {
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
943
|
+
function App() {
|
|
944
|
+
return <>
|
|
945
|
+
const selected = track([]);
|
|
946
|
+
<div>
|
|
947
|
+
<input type="checkbox" value="a" ref={bindGroup(selected)} />
|
|
948
|
+
<input type="checkbox" value="b" ref={bindGroup(selected)} />
|
|
949
|
+
</div>
|
|
950
|
+
</>;
|
|
932
951
|
}
|
|
933
952
|
|
|
934
953
|
render(App);
|
|
@@ -948,21 +967,22 @@ describe('use value()', () => {
|
|
|
948
967
|
});
|
|
949
968
|
|
|
950
969
|
it('should handle checkbox group with initial empty array with a getter and setter', () => {
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
970
|
+
function App() {
|
|
971
|
+
return <>
|
|
972
|
+
const selected: RippleObject<{ value: string[] }> = new RippleObject({ value: [] });
|
|
973
|
+
<div>
|
|
974
|
+
<input
|
|
975
|
+
type="checkbox"
|
|
976
|
+
value="a"
|
|
977
|
+
ref={bindGroup(() => selected.value, (v: string[]) => (selected.value = v))}
|
|
978
|
+
/>
|
|
979
|
+
<input
|
|
980
|
+
type="checkbox"
|
|
981
|
+
value="b"
|
|
982
|
+
ref={bindGroup(() => selected.value, (v: string[]) => (selected.value = v))}
|
|
983
|
+
/>
|
|
984
|
+
</div>
|
|
985
|
+
</>;
|
|
966
986
|
}
|
|
967
987
|
|
|
968
988
|
render(App);
|
|
@@ -982,10 +1002,11 @@ describe('use value()', () => {
|
|
|
982
1002
|
});
|
|
983
1003
|
|
|
984
1004
|
it('should handle number input type', () => {
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
1005
|
+
function App() {
|
|
1006
|
+
return <>
|
|
1007
|
+
const value = track(42);
|
|
1008
|
+
<input type="number" ref={bindValue(value)} />
|
|
1009
|
+
</>;
|
|
989
1010
|
}
|
|
990
1011
|
|
|
991
1012
|
render(App);
|
|
@@ -1002,10 +1023,11 @@ describe('use value()', () => {
|
|
|
1002
1023
|
});
|
|
1003
1024
|
|
|
1004
1025
|
it('should handle number input type with a getter and setter', () => {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1026
|
+
function App() {
|
|
1027
|
+
return <>
|
|
1028
|
+
const obj = new RippleObject({ value: 42 });
|
|
1029
|
+
<input type="number" ref={bindValue(() => obj.value, (v) => (obj.value = v))} />
|
|
1030
|
+
</>;
|
|
1009
1031
|
}
|
|
1010
1032
|
|
|
1011
1033
|
render(App);
|
|
@@ -1022,13 +1044,14 @@ describe('use value()', () => {
|
|
|
1022
1044
|
});
|
|
1023
1045
|
|
|
1024
1046
|
it('should update number input element when tracked value changes', () => {
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1047
|
+
function App() {
|
|
1048
|
+
return <>
|
|
1049
|
+
const value = track(10);
|
|
1050
|
+
<div>
|
|
1051
|
+
<input type="number" ref={bindValue(value)} />
|
|
1052
|
+
<button onClick={() => (value.value = 99)}>{'Update'}</button>
|
|
1053
|
+
</div>
|
|
1054
|
+
</>;
|
|
1032
1055
|
}
|
|
1033
1056
|
|
|
1034
1057
|
render(App);
|
|
@@ -1048,13 +1071,14 @@ describe('use value()', () => {
|
|
|
1048
1071
|
it(
|
|
1049
1072
|
'should update number input element when tracked value changes with a getter and setter',
|
|
1050
1073
|
() => {
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1074
|
+
function App() {
|
|
1075
|
+
return <>
|
|
1076
|
+
const obj = new RippleObject({ value: 10 });
|
|
1077
|
+
<div>
|
|
1078
|
+
<input type="number" ref={bindValue(() => obj.value, (v) => (obj.value = v))} />
|
|
1079
|
+
<button onClick={() => (obj.value = 99)}>{'Update'}</button>
|
|
1080
|
+
</div>
|
|
1081
|
+
</>;
|
|
1058
1082
|
}
|
|
1059
1083
|
|
|
1060
1084
|
render(App);
|
|
@@ -1073,10 +1097,11 @@ describe('use value()', () => {
|
|
|
1073
1097
|
);
|
|
1074
1098
|
|
|
1075
1099
|
it('should handle range input type', () => {
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1100
|
+
function App() {
|
|
1101
|
+
return <>
|
|
1102
|
+
const value = track(50);
|
|
1103
|
+
<input type="range" min="0" max="100" ref={bindValue(value)} />
|
|
1104
|
+
</>;
|
|
1080
1105
|
}
|
|
1081
1106
|
|
|
1082
1107
|
render(App);
|
|
@@ -1093,15 +1118,16 @@ describe('use value()', () => {
|
|
|
1093
1118
|
});
|
|
1094
1119
|
|
|
1095
1120
|
it('should handle range input type with a getter and setter', () => {
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1121
|
+
function App() {
|
|
1122
|
+
return <>
|
|
1123
|
+
const obj = new RippleObject({ value: 50 });
|
|
1124
|
+
<input
|
|
1125
|
+
type="range"
|
|
1126
|
+
min="0"
|
|
1127
|
+
max="100"
|
|
1128
|
+
ref={bindValue(() => obj.value, (v) => (obj.value = v))}
|
|
1129
|
+
/>
|
|
1130
|
+
</>;
|
|
1105
1131
|
}
|
|
1106
1132
|
|
|
1107
1133
|
render(App);
|
|
@@ -1118,13 +1144,14 @@ describe('use value()', () => {
|
|
|
1118
1144
|
});
|
|
1119
1145
|
|
|
1120
1146
|
it('should update range input element when tracked value changes', () => {
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1147
|
+
function App() {
|
|
1148
|
+
return <>
|
|
1149
|
+
const value = track(25);
|
|
1150
|
+
<div>
|
|
1151
|
+
<input type="range" min="0" max="100" ref={bindValue(value)} />
|
|
1152
|
+
<button onClick={() => (value.value = 80)}>{'Update'}</button>
|
|
1153
|
+
</div>
|
|
1154
|
+
</>;
|
|
1128
1155
|
}
|
|
1129
1156
|
|
|
1130
1157
|
render(App);
|
|
@@ -1144,18 +1171,19 @@ describe('use value()', () => {
|
|
|
1144
1171
|
it(
|
|
1145
1172
|
'should update range input element when tracked value changes with a getter and setter',
|
|
1146
1173
|
() => {
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1174
|
+
function App() {
|
|
1175
|
+
return <>
|
|
1176
|
+
const obj = new RippleObject({ value: 25 });
|
|
1177
|
+
<div>
|
|
1178
|
+
<input
|
|
1179
|
+
type="range"
|
|
1180
|
+
min="0"
|
|
1181
|
+
max="100"
|
|
1182
|
+
ref={bindValue(() => obj.value, (v) => (obj.value = v))}
|
|
1183
|
+
/>
|
|
1184
|
+
<button onClick={() => (obj.value = 80)}>{'Update'}</button>
|
|
1185
|
+
</div>
|
|
1186
|
+
</>;
|
|
1159
1187
|
}
|
|
1160
1188
|
|
|
1161
1189
|
render(App);
|
|
@@ -1174,10 +1202,11 @@ describe('use value()', () => {
|
|
|
1174
1202
|
);
|
|
1175
1203
|
|
|
1176
1204
|
it('should handle empty number input as null', () => {
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1205
|
+
function App() {
|
|
1206
|
+
return <>
|
|
1207
|
+
const value = track(null);
|
|
1208
|
+
<input type="number" ref={bindValue(value)} />
|
|
1209
|
+
</>;
|
|
1181
1210
|
}
|
|
1182
1211
|
|
|
1183
1212
|
render(App);
|
|
@@ -1194,10 +1223,11 @@ describe('use value()', () => {
|
|
|
1194
1223
|
});
|
|
1195
1224
|
|
|
1196
1225
|
it('should handle empty number input as null with a getter and setter', () => {
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1226
|
+
function App() {
|
|
1227
|
+
return <>
|
|
1228
|
+
const obj = new RippleObject({ value: null });
|
|
1229
|
+
<input type="number" ref={bindValue(() => obj.value, (v) => (obj.value = v))} />
|
|
1230
|
+
</>;
|
|
1201
1231
|
}
|
|
1202
1232
|
|
|
1203
1233
|
render(App);
|
|
@@ -1214,10 +1244,11 @@ describe('use value()', () => {
|
|
|
1214
1244
|
});
|
|
1215
1245
|
|
|
1216
1246
|
it('should handle date input type', () => {
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1247
|
+
function App() {
|
|
1248
|
+
return <>
|
|
1249
|
+
const value = track('2025-11-14');
|
|
1250
|
+
<input type="date" ref={bindValue(value)} />
|
|
1251
|
+
</>;
|
|
1221
1252
|
}
|
|
1222
1253
|
|
|
1223
1254
|
render(App);
|
|
@@ -1234,10 +1265,11 @@ describe('use value()', () => {
|
|
|
1234
1265
|
});
|
|
1235
1266
|
|
|
1236
1267
|
it('should handle date input type with a getter and setter', () => {
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1268
|
+
function App() {
|
|
1269
|
+
return <>
|
|
1270
|
+
const obj = new RippleObject({ value: '2025-11-14' });
|
|
1271
|
+
<input type="date" ref={bindValue(() => obj.value, (v) => (obj.value = v))} />
|
|
1272
|
+
</>;
|
|
1241
1273
|
}
|
|
1242
1274
|
|
|
1243
1275
|
render(App);
|
|
@@ -1254,13 +1286,14 @@ describe('use value()', () => {
|
|
|
1254
1286
|
});
|
|
1255
1287
|
|
|
1256
1288
|
it('should update date input element when tracked value changes', () => {
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1289
|
+
function App() {
|
|
1290
|
+
return <>
|
|
1291
|
+
const value = track('2025-01-01');
|
|
1292
|
+
<div>
|
|
1293
|
+
<input type="date" ref={bindValue(value)} />
|
|
1294
|
+
<button onClick={() => (value.value = '2025-12-31')}>{'Update'}</button>
|
|
1295
|
+
</div>
|
|
1296
|
+
</>;
|
|
1264
1297
|
}
|
|
1265
1298
|
|
|
1266
1299
|
render(App);
|
|
@@ -1278,13 +1311,14 @@ describe('use value()', () => {
|
|
|
1278
1311
|
});
|
|
1279
1312
|
|
|
1280
1313
|
it('should update date input element when tracked value changes with a getter and setter', () => {
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1314
|
+
function App() {
|
|
1315
|
+
return <>
|
|
1316
|
+
const obj = new RippleObject({ value: '2025-01-01' });
|
|
1317
|
+
<div>
|
|
1318
|
+
<input type="date" ref={bindValue(() => obj.value, (v) => (obj.value = v))} />
|
|
1319
|
+
<button onClick={() => (obj.value = '2025-12-31')}>{'Update'}</button>
|
|
1320
|
+
</div>
|
|
1321
|
+
</>;
|
|
1288
1322
|
}
|
|
1289
1323
|
|
|
1290
1324
|
render(App);
|
|
@@ -1302,15 +1336,16 @@ describe('use value()', () => {
|
|
|
1302
1336
|
});
|
|
1303
1337
|
|
|
1304
1338
|
it('should handle select with multiple attribute', () => {
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1339
|
+
function App() {
|
|
1340
|
+
return <>
|
|
1341
|
+
const selected = track(['2', '3']);
|
|
1342
|
+
<select multiple ref={bindValue(selected)}>
|
|
1343
|
+
<option value="1">{'One'}</option>
|
|
1344
|
+
<option value="2">{'Two'}</option>
|
|
1345
|
+
<option value="3">{'Three'}</option>
|
|
1346
|
+
<option value="4">{'Four'}</option>
|
|
1347
|
+
</select>
|
|
1348
|
+
</>;
|
|
1314
1349
|
}
|
|
1315
1350
|
|
|
1316
1351
|
render(App);
|
|
@@ -1336,15 +1371,16 @@ describe('use value()', () => {
|
|
|
1336
1371
|
});
|
|
1337
1372
|
|
|
1338
1373
|
it('should handle select with multiple attribute with a getter and setter', () => {
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1374
|
+
function App() {
|
|
1375
|
+
return <>
|
|
1376
|
+
const selected = track(['2', '3']);
|
|
1377
|
+
<select multiple ref={bindValue(() => selected.value, (v) => (selected.value = v))}>
|
|
1378
|
+
<option value="1">{'One'}</option>
|
|
1379
|
+
<option value="2">{'Two'}</option>
|
|
1380
|
+
<option value="3">{'Three'}</option>
|
|
1381
|
+
<option value="4">{'Four'}</option>
|
|
1382
|
+
</select>
|
|
1383
|
+
</>;
|
|
1348
1384
|
}
|
|
1349
1385
|
|
|
1350
1386
|
render(App);
|
|
@@ -1370,18 +1406,19 @@ describe('use value()', () => {
|
|
|
1370
1406
|
});
|
|
1371
1407
|
|
|
1372
1408
|
it('should update multiple select element when tracked value changes', () => {
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1409
|
+
function App() {
|
|
1410
|
+
return <>
|
|
1411
|
+
const selected = track(['1']);
|
|
1412
|
+
<div>
|
|
1413
|
+
<select multiple ref={bindValue(selected)}>
|
|
1414
|
+
<option value="1">{'One'}</option>
|
|
1415
|
+
<option value="2">{'Two'}</option>
|
|
1416
|
+
<option value="3">{'Three'}</option>
|
|
1417
|
+
<option value="4">{'Four'}</option>
|
|
1418
|
+
</select>
|
|
1419
|
+
<button onClick={() => (selected.value = ['2', '4'])}>{'Update'}</button>
|
|
1420
|
+
</div>
|
|
1421
|
+
</>;
|
|
1385
1422
|
}
|
|
1386
1423
|
|
|
1387
1424
|
render(App);
|
|
@@ -1408,18 +1445,19 @@ describe('use value()', () => {
|
|
|
1408
1445
|
it(
|
|
1409
1446
|
'should update multiple select element when tracked value changes with a getter and setter',
|
|
1410
1447
|
() => {
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1448
|
+
function App() {
|
|
1449
|
+
return <>
|
|
1450
|
+
const selected = track(['1']);
|
|
1451
|
+
<div>
|
|
1452
|
+
<select multiple ref={bindValue(() => selected.value, (v) => (selected.value = v))}>
|
|
1453
|
+
<option value="1">{'One'}</option>
|
|
1454
|
+
<option value="2">{'Two'}</option>
|
|
1455
|
+
<option value="3">{'Three'}</option>
|
|
1456
|
+
<option value="4">{'Four'}</option>
|
|
1457
|
+
</select>
|
|
1458
|
+
<button onClick={() => (selected.value = ['2', '4'])}>{'Update'}</button>
|
|
1459
|
+
</div>
|
|
1460
|
+
</>;
|
|
1423
1461
|
}
|
|
1424
1462
|
|
|
1425
1463
|
render(App);
|
|
@@ -1445,13 +1483,14 @@ describe('use value()', () => {
|
|
|
1445
1483
|
);
|
|
1446
1484
|
|
|
1447
1485
|
it('should handle select without initial value and fall back to first option', () => {
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1486
|
+
function App() {
|
|
1487
|
+
return <>
|
|
1488
|
+
const selected = track();
|
|
1489
|
+
<select ref={bindValue(selected)}>
|
|
1490
|
+
<option value="1">{'One'}</option>
|
|
1491
|
+
<option value="2">{'Two'}</option>
|
|
1492
|
+
</select>
|
|
1493
|
+
</>;
|
|
1455
1494
|
}
|
|
1456
1495
|
|
|
1457
1496
|
render(App);
|
|
@@ -1465,13 +1504,14 @@ describe('use value()', () => {
|
|
|
1465
1504
|
it(
|
|
1466
1505
|
'should handle select without initial value and fall back to first option with a getter and setter',
|
|
1467
1506
|
() => {
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1507
|
+
function App() {
|
|
1508
|
+
return <>
|
|
1509
|
+
const selected = track();
|
|
1510
|
+
<select ref={bindValue(() => selected.value, (v) => (selected.value = v))}>
|
|
1511
|
+
<option value="1">{'One'}</option>
|
|
1512
|
+
<option value="2">{'Two'}</option>
|
|
1513
|
+
</select>
|
|
1514
|
+
</>;
|
|
1475
1515
|
}
|
|
1476
1516
|
|
|
1477
1517
|
render(App);
|
|
@@ -1484,13 +1524,14 @@ describe('use value()', () => {
|
|
|
1484
1524
|
);
|
|
1485
1525
|
|
|
1486
1526
|
it('should handle select with disabled options', () => {
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1527
|
+
function App() {
|
|
1528
|
+
return <>
|
|
1529
|
+
const selected = track();
|
|
1530
|
+
<select ref={bindValue(selected)}>
|
|
1531
|
+
<option value="1" disabled>{'One'}</option>
|
|
1532
|
+
<option value="2">{'Two'}</option>
|
|
1533
|
+
</select>
|
|
1534
|
+
</>;
|
|
1494
1535
|
}
|
|
1495
1536
|
|
|
1496
1537
|
render(App);
|
|
@@ -1502,13 +1543,14 @@ describe('use value()', () => {
|
|
|
1502
1543
|
});
|
|
1503
1544
|
|
|
1504
1545
|
it('should handle select with disabled options with a getter and setter', () => {
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1546
|
+
function App() {
|
|
1547
|
+
return <>
|
|
1548
|
+
const selected = track();
|
|
1549
|
+
<select ref={bindValue(() => selected.value, (v) => (selected.value = v))}>
|
|
1550
|
+
<option value="1" disabled>{'One'}</option>
|
|
1551
|
+
<option value="2">{'Two'}</option>
|
|
1552
|
+
</select>
|
|
1553
|
+
</>;
|
|
1512
1554
|
}
|
|
1513
1555
|
|
|
1514
1556
|
render(App);
|
|
@@ -1520,14 +1562,15 @@ describe('use value()', () => {
|
|
|
1520
1562
|
});
|
|
1521
1563
|
|
|
1522
1564
|
it('should preselect numeric option values in select bindValue', () => {
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1565
|
+
function App() {
|
|
1566
|
+
return <>
|
|
1567
|
+
const selected = track(2);
|
|
1568
|
+
<select ref={bindValue(selected)}>
|
|
1569
|
+
<option value={1}>{'One'}</option>
|
|
1570
|
+
<option value={2}>{'Two'}</option>
|
|
1571
|
+
<option value={3}>{'Three'}</option>
|
|
1572
|
+
</select>
|
|
1573
|
+
</>;
|
|
1531
1574
|
}
|
|
1532
1575
|
|
|
1533
1576
|
render(App);
|
|
@@ -1542,14 +1585,15 @@ describe('use value()', () => {
|
|
|
1542
1585
|
});
|
|
1543
1586
|
|
|
1544
1587
|
it('should preselect numeric option values in select bindValue with a getter and setter', () => {
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1588
|
+
function App() {
|
|
1589
|
+
return <>
|
|
1590
|
+
const selected = track(2);
|
|
1591
|
+
<select ref={bindValue(() => selected.value, (v) => (selected.value = v))}>
|
|
1592
|
+
<option value={1}>{'One'}</option>
|
|
1593
|
+
<option value={2}>{'Two'}</option>
|
|
1594
|
+
<option value={3}>{'Three'}</option>
|
|
1595
|
+
</select>
|
|
1596
|
+
</>;
|
|
1553
1597
|
}
|
|
1554
1598
|
|
|
1555
1599
|
render(App);
|
|
@@ -1566,18 +1610,18 @@ describe('use value()', () => {
|
|
|
1566
1610
|
it('should preserve numeric select values on change', () => {
|
|
1567
1611
|
const logs: number[] = [];
|
|
1568
1612
|
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1613
|
+
function App() {
|
|
1614
|
+
return <>
|
|
1615
|
+
const selected = track(2);
|
|
1616
|
+
effect(() => {
|
|
1617
|
+
logs.push(selected.value);
|
|
1618
|
+
});
|
|
1619
|
+
<select ref={bindValue(selected)}>
|
|
1620
|
+
<option value={1}>{'One'}</option>
|
|
1621
|
+
<option value={2}>{'Two'}</option>
|
|
1622
|
+
<option value={3}>{'Three'}</option>
|
|
1623
|
+
</select>
|
|
1624
|
+
</>;
|
|
1581
1625
|
}
|
|
1582
1626
|
|
|
1583
1627
|
render(App);
|
|
@@ -1593,21 +1637,22 @@ describe('use value()', () => {
|
|
|
1593
1637
|
});
|
|
1594
1638
|
|
|
1595
1639
|
it('should reselect tracked value when matching option is added later', async () => {
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1640
|
+
function App() {
|
|
1641
|
+
return <>
|
|
1642
|
+
const selected = track(5);
|
|
1643
|
+
const options = RippleArray([
|
|
1644
|
+
{ id: 1, text: 'One' },
|
|
1645
|
+
{ id: 2, text: 'Two' },
|
|
1646
|
+
]);
|
|
1647
|
+
<div>
|
|
1648
|
+
<select ref={bindValue(selected)}>
|
|
1649
|
+
for (const option of options) {
|
|
1650
|
+
<option value={option.id}>{option.text}</option>
|
|
1651
|
+
}
|
|
1652
|
+
</select>
|
|
1653
|
+
<button onClick={() => options.push({ id: 5, text: 'Five' })}>{'Add'}</button>
|
|
1654
|
+
</div>
|
|
1655
|
+
</>;
|
|
1611
1656
|
}
|
|
1612
1657
|
|
|
1613
1658
|
render(App);
|
|
@@ -1628,25 +1673,25 @@ describe('use value()', () => {
|
|
|
1628
1673
|
});
|
|
1629
1674
|
|
|
1630
1675
|
it('should reselect tracked value when option lists are replaced later', async () => {
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1676
|
+
function App() {
|
|
1677
|
+
return <>
|
|
1678
|
+
const selected = track(22);
|
|
1679
|
+
const options = RippleArray([
|
|
1680
|
+
{ id: 1, text: 'One' },
|
|
1681
|
+
]);
|
|
1682
|
+
effect(() => {
|
|
1683
|
+
const timeout = setTimeout(() => {
|
|
1684
|
+
options.splice(0, options.length, { id: 21, text: 'Tokyo' }, { id: 22, text: 'Osaka' });
|
|
1685
|
+
}, 0);
|
|
1686
|
+
|
|
1687
|
+
return () => clearTimeout(timeout);
|
|
1688
|
+
});
|
|
1689
|
+
<select ref={bindValue(selected)}>
|
|
1690
|
+
for (const option of options) {
|
|
1691
|
+
<option value={option.id}>{option.text}</option>
|
|
1692
|
+
}
|
|
1693
|
+
</select>
|
|
1694
|
+
</>;
|
|
1650
1695
|
}
|
|
1651
1696
|
|
|
1652
1697
|
render(App);
|
|
@@ -1661,22 +1706,23 @@ describe('use value()', () => {
|
|
|
1661
1706
|
});
|
|
1662
1707
|
|
|
1663
1708
|
it('should accurately reflect values mutated through a tracked setter', () => {
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1709
|
+
function App() {
|
|
1710
|
+
return <>
|
|
1711
|
+
let value = track(
|
|
1712
|
+
'',
|
|
1713
|
+
(val) => {
|
|
1714
|
+
return val;
|
|
1715
|
+
},
|
|
1716
|
+
(next) => {
|
|
1717
|
+
if (next.includes('c')) {
|
|
1718
|
+
next = next.replace(/c/g, '');
|
|
1719
|
+
}
|
|
1720
|
+
return next;
|
|
1721
|
+
},
|
|
1722
|
+
);
|
|
1723
|
+
<input type="text" ref={bindValue(value)} />
|
|
1724
|
+
<div>{value.value}</div>
|
|
1725
|
+
</>;
|
|
1680
1726
|
}
|
|
1681
1727
|
|
|
1682
1728
|
render(App);
|
|
@@ -1697,22 +1743,23 @@ describe('use value()', () => {
|
|
|
1697
1743
|
});
|
|
1698
1744
|
|
|
1699
1745
|
it('should accurately reflect values when a getter modifies value', () => {
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1746
|
+
function App() {
|
|
1747
|
+
return <>
|
|
1748
|
+
let value = track(
|
|
1749
|
+
'',
|
|
1750
|
+
(val) => {
|
|
1751
|
+
if (val.includes('c')) {
|
|
1752
|
+
val = val.replace(/c/g, '');
|
|
1753
|
+
}
|
|
1754
|
+
return val;
|
|
1755
|
+
},
|
|
1756
|
+
(next) => {
|
|
1757
|
+
return next;
|
|
1758
|
+
},
|
|
1759
|
+
);
|
|
1760
|
+
<input type="text" ref={bindValue(value)} />
|
|
1761
|
+
<div>{value.value}</div>
|
|
1762
|
+
</>;
|
|
1716
1763
|
}
|
|
1717
1764
|
|
|
1718
1765
|
render(App);
|
|
@@ -1733,22 +1780,23 @@ describe('use value()', () => {
|
|
|
1733
1780
|
});
|
|
1734
1781
|
|
|
1735
1782
|
it('should always prefer what getter returns even if setter mutates next', () => {
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1783
|
+
function App() {
|
|
1784
|
+
return <>
|
|
1785
|
+
let value = track(
|
|
1786
|
+
'',
|
|
1787
|
+
(val) => {
|
|
1788
|
+
return val.replace(/[c,b]+/g, '');
|
|
1789
|
+
},
|
|
1790
|
+
(next) => {
|
|
1791
|
+
if (next.includes('c')) {
|
|
1792
|
+
next = next.replace(/c/g, '');
|
|
1793
|
+
}
|
|
1794
|
+
return next;
|
|
1795
|
+
},
|
|
1796
|
+
);
|
|
1797
|
+
<input type="text" ref={bindValue(value)} />
|
|
1798
|
+
<div>{value.value}</div>
|
|
1799
|
+
</>;
|
|
1752
1800
|
}
|
|
1753
1801
|
|
|
1754
1802
|
render(App);
|
|
@@ -1771,31 +1819,32 @@ describe('use value()', () => {
|
|
|
1771
1819
|
it(
|
|
1772
1820
|
'should accurately reflect values mutated through an effect even after a setter mutation',
|
|
1773
1821
|
() => {
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1822
|
+
function App() {
|
|
1823
|
+
return <>
|
|
1824
|
+
let value = track(
|
|
1825
|
+
'',
|
|
1826
|
+
(val) => {
|
|
1827
|
+
return val;
|
|
1828
|
+
},
|
|
1829
|
+
(next) => {
|
|
1830
|
+
if (next.includes('c')) {
|
|
1831
|
+
next = next.replace(/c/g, '');
|
|
1832
|
+
}
|
|
1833
|
+
return next;
|
|
1834
|
+
},
|
|
1835
|
+
);
|
|
1836
|
+
effect(() => {
|
|
1837
|
+
value.value;
|
|
1838
|
+
|
|
1839
|
+
untrack(() => {
|
|
1840
|
+
if (value.value.includes('a')) {
|
|
1841
|
+
value.value = value.value.replace(/a/g, '');
|
|
1842
|
+
}
|
|
1843
|
+
});
|
|
1795
1844
|
});
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1845
|
+
<input type="text" ref={bindValue(value)} />
|
|
1846
|
+
<div>{value.value}</div>
|
|
1847
|
+
</>;
|
|
1799
1848
|
}
|
|
1800
1849
|
|
|
1801
1850
|
render(App);
|
|
@@ -1817,21 +1866,22 @@ describe('use value()', () => {
|
|
|
1817
1866
|
);
|
|
1818
1867
|
|
|
1819
1868
|
it('should accurately reflect values mutated through a tracked setter via bind accessors', () => {
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1869
|
+
function App() {
|
|
1870
|
+
return <>
|
|
1871
|
+
let value = track('');
|
|
1872
|
+
const value_accessors: [GetFunction<string>, SetFunction<string>] = [
|
|
1873
|
+
() => {
|
|
1874
|
+
return value.value;
|
|
1875
|
+
},
|
|
1876
|
+
(v: string) => {
|
|
1877
|
+
if (v.includes('c')) {
|
|
1878
|
+
v = v.replace(/c/g, '');
|
|
1879
|
+
}
|
|
1880
|
+
value.value = v;
|
|
1881
|
+
},
|
|
1882
|
+
];
|
|
1883
|
+
<input type="text" ref={bindValue(...value_accessors)} />
|
|
1884
|
+
</>;
|
|
1835
1885
|
}
|
|
1836
1886
|
|
|
1837
1887
|
render(App);
|
|
@@ -1849,21 +1899,22 @@ describe('use value()', () => {
|
|
|
1849
1899
|
});
|
|
1850
1900
|
|
|
1851
1901
|
it('should prefer what getter returns via bind accessors', () => {
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1902
|
+
function App() {
|
|
1903
|
+
return <>
|
|
1904
|
+
let value = track('');
|
|
1905
|
+
const value_accessors: [GetFunction<string>, SetFunction<string>] = [
|
|
1906
|
+
() => {
|
|
1907
|
+
if (value.value.includes('c')) {
|
|
1908
|
+
return value.value.replace(/c/g, '');
|
|
1909
|
+
}
|
|
1910
|
+
return value.value;
|
|
1911
|
+
},
|
|
1912
|
+
(v: string) => {
|
|
1913
|
+
value.value = v;
|
|
1914
|
+
},
|
|
1915
|
+
];
|
|
1916
|
+
<input type="text" ref={bindValue(...value_accessors)} />
|
|
1917
|
+
</>;
|
|
1867
1918
|
}
|
|
1868
1919
|
|
|
1869
1920
|
render(App);
|
|
@@ -1883,21 +1934,22 @@ describe('use value()', () => {
|
|
|
1883
1934
|
it(
|
|
1884
1935
|
'should always prefer what getter returns even if setter mutates next via bind accessors',
|
|
1885
1936
|
() => {
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1937
|
+
function App() {
|
|
1938
|
+
return <>
|
|
1939
|
+
let value = track('');
|
|
1940
|
+
const value_accessors: [GetFunction<string>, SetFunction<string>] = [
|
|
1941
|
+
() => {
|
|
1942
|
+
return value.value.replace(/[c,b]+/g, '');
|
|
1943
|
+
},
|
|
1944
|
+
(v: string) => {
|
|
1945
|
+
if (v.includes('c')) {
|
|
1946
|
+
v = v.replace(/c/g, '');
|
|
1947
|
+
}
|
|
1948
|
+
value.value = v;
|
|
1949
|
+
},
|
|
1950
|
+
];
|
|
1951
|
+
<input type="text" ref={bindValue(...value_accessors)} />
|
|
1952
|
+
</>;
|
|
1901
1953
|
}
|
|
1902
1954
|
|
|
1903
1955
|
render(App);
|
|
@@ -1918,30 +1970,31 @@ describe('use value()', () => {
|
|
|
1918
1970
|
it(
|
|
1919
1971
|
'should accurately reflect values mutated through an effect even after a setter mutation via bind accessors',
|
|
1920
1972
|
() => {
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1973
|
+
function App() {
|
|
1974
|
+
return <>
|
|
1975
|
+
let value = track('');
|
|
1976
|
+
const value_accessors: [GetFunction<string>, SetFunction<string>] = [
|
|
1977
|
+
() => {
|
|
1978
|
+
return value.value;
|
|
1979
|
+
},
|
|
1980
|
+
(v: string) => {
|
|
1981
|
+
if (v.includes('c')) {
|
|
1982
|
+
v = v.replace(/c/g, '');
|
|
1983
|
+
}
|
|
1984
|
+
value.value = v;
|
|
1985
|
+
},
|
|
1986
|
+
];
|
|
1987
|
+
effect(() => {
|
|
1988
|
+
value.value;
|
|
1989
|
+
|
|
1990
|
+
untrack(() => {
|
|
1991
|
+
if (value.value.includes('a')) {
|
|
1992
|
+
value.value = value.value.replace(/a/g, '');
|
|
1993
|
+
}
|
|
1994
|
+
});
|
|
1942
1995
|
});
|
|
1943
|
-
|
|
1944
|
-
|
|
1996
|
+
<input type="text" ref={bindValue(...value_accessors)} />
|
|
1997
|
+
</>;
|
|
1945
1998
|
}
|
|
1946
1999
|
|
|
1947
2000
|
render(App);
|
|
@@ -1962,19 +2015,20 @@ describe('use value()', () => {
|
|
|
1962
2015
|
it(
|
|
1963
2016
|
'should keep the input.value unchanged and synced with the tracked when the setter blocks updates to the tracked via bind accessors',
|
|
1964
2017
|
() => {
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
1970
|
-
|
|
1971
|
-
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
2018
|
+
function App() {
|
|
2019
|
+
return <>
|
|
2020
|
+
let value = track('');
|
|
2021
|
+
const value_accessors: [GetFunction<string>, SetFunction<string>] = [
|
|
2022
|
+
() => {
|
|
2023
|
+
return value.value;
|
|
2024
|
+
},
|
|
2025
|
+
(v: string) => {
|
|
2026
|
+
// no update
|
|
2027
|
+
},
|
|
2028
|
+
];
|
|
2029
|
+
<input type="text" ref={bindValue(...value_accessors)} />
|
|
2030
|
+
<div>{value.value}</div>
|
|
2031
|
+
</>;
|
|
1978
2032
|
}
|
|
1979
2033
|
|
|
1980
2034
|
render(App);
|
|
@@ -1997,19 +2051,20 @@ describe('use value()', () => {
|
|
|
1997
2051
|
it(
|
|
1998
2052
|
'should keep the input.value unchanged and synced with the tracked when the setter blocks updates to the tracked via track get / set',
|
|
1999
2053
|
() => {
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2054
|
+
function App() {
|
|
2055
|
+
return <>
|
|
2056
|
+
let value = track(
|
|
2057
|
+
'',
|
|
2058
|
+
(v) => {
|
|
2059
|
+
return v;
|
|
2060
|
+
},
|
|
2061
|
+
() => {
|
|
2062
|
+
return '';
|
|
2063
|
+
},
|
|
2064
|
+
);
|
|
2065
|
+
<input type="text" ref={bindValue(value)} />
|
|
2066
|
+
<div>{value.value}</div>
|
|
2067
|
+
</>;
|
|
2013
2068
|
}
|
|
2014
2069
|
|
|
2015
2070
|
render(App);
|
|
@@ -2034,14 +2089,14 @@ describe('bindClientWidth and bindClientHeight', () => {
|
|
|
2034
2089
|
it('should bind element clientWidth', () => {
|
|
2035
2090
|
const logs: number[] = [];
|
|
2036
2091
|
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
|
|
2042
|
-
|
|
2043
|
-
|
|
2044
|
-
|
|
2092
|
+
function App() {
|
|
2093
|
+
return <>
|
|
2094
|
+
const width = track(0);
|
|
2095
|
+
effect(() => {
|
|
2096
|
+
logs.push(width.value);
|
|
2097
|
+
});
|
|
2098
|
+
<div ref={bindClientWidth(width)} />
|
|
2099
|
+
</>;
|
|
2045
2100
|
}
|
|
2046
2101
|
|
|
2047
2102
|
render(App);
|
|
@@ -2065,14 +2120,14 @@ describe('bindClientWidth and bindClientHeight', () => {
|
|
|
2065
2120
|
it('should bind element clientWidth with a getter and setter', () => {
|
|
2066
2121
|
const logs: number[] = [];
|
|
2067
2122
|
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2123
|
+
function App() {
|
|
2124
|
+
return <>
|
|
2125
|
+
const width = new RippleObject({ value: 0 });
|
|
2126
|
+
effect(() => {
|
|
2127
|
+
logs.push(width.value);
|
|
2128
|
+
});
|
|
2129
|
+
<div ref={bindClientWidth(() => width.value, (v: number) => (width.value = v))} />
|
|
2130
|
+
</>;
|
|
2076
2131
|
}
|
|
2077
2132
|
|
|
2078
2133
|
render(App);
|
|
@@ -2096,14 +2151,14 @@ describe('bindClientWidth and bindClientHeight', () => {
|
|
|
2096
2151
|
it('should bind element clientHeight', () => {
|
|
2097
2152
|
const logs: number[] = [];
|
|
2098
2153
|
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2154
|
+
function App() {
|
|
2155
|
+
return <>
|
|
2156
|
+
const height = track(0);
|
|
2157
|
+
effect(() => {
|
|
2158
|
+
logs.push(height.value);
|
|
2159
|
+
});
|
|
2160
|
+
<div ref={bindClientHeight(height)} />
|
|
2161
|
+
</>;
|
|
2107
2162
|
}
|
|
2108
2163
|
|
|
2109
2164
|
render(App);
|
|
@@ -2127,13 +2182,14 @@ describe('bindClientWidth and bindClientHeight', () => {
|
|
|
2127
2182
|
it('should bind element clientHeight with a getter and setter', () => {
|
|
2128
2183
|
const logs: number[] = [];
|
|
2129
2184
|
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2185
|
+
function App() {
|
|
2186
|
+
return <>
|
|
2187
|
+
const height = new RippleObject({ value: 0 });
|
|
2188
|
+
effect(() => {
|
|
2189
|
+
logs.push(height.value);
|
|
2190
|
+
});
|
|
2191
|
+
<div ref={bindClientHeight(() => height.value, (v: number) => (height.value = v))} />
|
|
2192
|
+
</>;
|
|
2137
2193
|
}
|
|
2138
2194
|
|
|
2139
2195
|
render(App);
|
|
@@ -2159,14 +2215,14 @@ describe('bindOffsetWidth and bindOffsetHeight', () => {
|
|
|
2159
2215
|
it('should bind element offsetWidth', () => {
|
|
2160
2216
|
const logs: number[] = [];
|
|
2161
2217
|
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2218
|
+
function App() {
|
|
2219
|
+
return <>
|
|
2220
|
+
const width = track(0);
|
|
2221
|
+
effect(() => {
|
|
2222
|
+
logs.push(width.value);
|
|
2223
|
+
});
|
|
2224
|
+
<div ref={bindOffsetWidth(width)} />
|
|
2225
|
+
</>;
|
|
2170
2226
|
}
|
|
2171
2227
|
|
|
2172
2228
|
render(App);
|
|
@@ -2190,14 +2246,14 @@ describe('bindOffsetWidth and bindOffsetHeight', () => {
|
|
|
2190
2246
|
it('should bind element offsetWidth with a getter and setter', () => {
|
|
2191
2247
|
const logs: number[] = [];
|
|
2192
2248
|
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2249
|
+
function App() {
|
|
2250
|
+
return <>
|
|
2251
|
+
const width = new RippleObject({ value: 0 });
|
|
2252
|
+
effect(() => {
|
|
2253
|
+
logs.push(width.value);
|
|
2254
|
+
});
|
|
2255
|
+
<div ref={bindOffsetWidth(() => width.value, (v: number) => (width.value = v))} />
|
|
2256
|
+
</>;
|
|
2201
2257
|
}
|
|
2202
2258
|
|
|
2203
2259
|
render(App);
|
|
@@ -2221,14 +2277,14 @@ describe('bindOffsetWidth and bindOffsetHeight', () => {
|
|
|
2221
2277
|
it('should bind element offsetHeight', () => {
|
|
2222
2278
|
const logs: number[] = [];
|
|
2223
2279
|
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2280
|
+
function App() {
|
|
2281
|
+
return <>
|
|
2282
|
+
const height = track(0);
|
|
2283
|
+
effect(() => {
|
|
2284
|
+
logs.push(height.value);
|
|
2285
|
+
});
|
|
2286
|
+
<div ref={bindOffsetHeight(height)} />
|
|
2287
|
+
</>;
|
|
2232
2288
|
}
|
|
2233
2289
|
|
|
2234
2290
|
render(App);
|
|
@@ -2252,13 +2308,14 @@ describe('bindOffsetWidth and bindOffsetHeight', () => {
|
|
|
2252
2308
|
it('should bind element offsetHeight with a getter and setter', () => {
|
|
2253
2309
|
const logs: number[] = [];
|
|
2254
2310
|
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2311
|
+
function App() {
|
|
2312
|
+
return <>
|
|
2313
|
+
const height = new RippleObject({ value: 0 });
|
|
2314
|
+
effect(() => {
|
|
2315
|
+
logs.push(height.value);
|
|
2316
|
+
});
|
|
2317
|
+
<div ref={bindOffsetHeight(() => height.value, (v: number) => (height.value = v))} />
|
|
2318
|
+
</>;
|
|
2262
2319
|
}
|
|
2263
2320
|
|
|
2264
2321
|
render(App);
|
|
@@ -2284,14 +2341,14 @@ describe('bindContentRect', () => {
|
|
|
2284
2341
|
it('should bind element contentRect', () => {
|
|
2285
2342
|
const logs: DOMRectReadOnly[] = [];
|
|
2286
2343
|
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2344
|
+
function App() {
|
|
2345
|
+
return <>
|
|
2346
|
+
const rect = track(null);
|
|
2347
|
+
effect(() => {
|
|
2348
|
+
if (rect.value) logs.push(rect.value);
|
|
2349
|
+
});
|
|
2350
|
+
<div ref={bindContentRect(rect)} />
|
|
2351
|
+
</>;
|
|
2295
2352
|
}
|
|
2296
2353
|
|
|
2297
2354
|
render(App);
|
|
@@ -2314,20 +2371,21 @@ describe('bindContentRect', () => {
|
|
|
2314
2371
|
it('should bind element contentRect with a getter and setter', () => {
|
|
2315
2372
|
const logs: DOMRectReadOnly[] = [];
|
|
2316
2373
|
|
|
2317
|
-
|
|
2318
|
-
|
|
2319
|
-
value: null
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
2330
|
-
|
|
2374
|
+
function App() {
|
|
2375
|
+
return <>
|
|
2376
|
+
const rect: RippleObject<{ value: DOMRectReadOnly | null }> = new RippleObject({
|
|
2377
|
+
value: null,
|
|
2378
|
+
});
|
|
2379
|
+
effect(() => {
|
|
2380
|
+
if (rect.value) logs.push(rect.value);
|
|
2381
|
+
});
|
|
2382
|
+
<div
|
|
2383
|
+
ref={bindContentRect<null | DOMRectReadOnly>(
|
|
2384
|
+
() => rect.value,
|
|
2385
|
+
(v: DOMRectReadOnly) => (rect.value = v),
|
|
2386
|
+
)}
|
|
2387
|
+
/>
|
|
2388
|
+
</>;
|
|
2331
2389
|
}
|
|
2332
2390
|
|
|
2333
2391
|
render(App);
|
|
@@ -2352,14 +2410,14 @@ describe('bindContentBoxSize', () => {
|
|
|
2352
2410
|
it('should bind element contentBoxSize', () => {
|
|
2353
2411
|
const logs: any[] = [];
|
|
2354
2412
|
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
|
|
2359
|
-
|
|
2360
|
-
|
|
2361
|
-
|
|
2362
|
-
|
|
2413
|
+
function App() {
|
|
2414
|
+
return <>
|
|
2415
|
+
const boxSize = track(null);
|
|
2416
|
+
effect(() => {
|
|
2417
|
+
if (boxSize.value) logs.push(boxSize.value);
|
|
2418
|
+
});
|
|
2419
|
+
<div ref={bindContentBoxSize(boxSize)} />
|
|
2420
|
+
</>;
|
|
2363
2421
|
}
|
|
2364
2422
|
|
|
2365
2423
|
render(App);
|
|
@@ -2385,21 +2443,21 @@ describe('bindContentBoxSize', () => {
|
|
|
2385
2443
|
{ blockSize: 200, inlineSize: 300 },
|
|
2386
2444
|
];
|
|
2387
2445
|
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
value: null
|
|
2391
|
-
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2446
|
+
function App() {
|
|
2447
|
+
return <>
|
|
2448
|
+
const boxSize: RippleObject<{ value: typeof mockBoxSize | null }> = new RippleObject({
|
|
2449
|
+
value: null,
|
|
2450
|
+
});
|
|
2451
|
+
effect(() => {
|
|
2452
|
+
if (boxSize.value) logs.push(boxSize.value);
|
|
2453
|
+
});
|
|
2454
|
+
<div
|
|
2455
|
+
ref={bindContentBoxSize<null | typeof mockBoxSize>(
|
|
2456
|
+
() => boxSize.value,
|
|
2457
|
+
(v: typeof mockBoxSize) => (boxSize.value = v),
|
|
2458
|
+
)}
|
|
2459
|
+
/>
|
|
2460
|
+
</>;
|
|
2403
2461
|
}
|
|
2404
2462
|
|
|
2405
2463
|
render(App);
|
|
@@ -2421,14 +2479,14 @@ describe('bindBorderBoxSize', () => {
|
|
|
2421
2479
|
it('should bind element borderBoxSize', () => {
|
|
2422
2480
|
const logs: any[] = [];
|
|
2423
2481
|
|
|
2424
|
-
|
|
2425
|
-
|
|
2426
|
-
|
|
2427
|
-
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2482
|
+
function App() {
|
|
2483
|
+
return <>
|
|
2484
|
+
const boxSize = track(null);
|
|
2485
|
+
effect(() => {
|
|
2486
|
+
if (boxSize.value) logs.push(boxSize.value);
|
|
2487
|
+
});
|
|
2488
|
+
<div ref={bindBorderBoxSize(boxSize)} />
|
|
2489
|
+
</>;
|
|
2432
2490
|
}
|
|
2433
2491
|
|
|
2434
2492
|
render(App);
|
|
@@ -2454,21 +2512,21 @@ describe('bindBorderBoxSize', () => {
|
|
|
2454
2512
|
{ blockSize: 220, inlineSize: 320 },
|
|
2455
2513
|
];
|
|
2456
2514
|
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
value: null
|
|
2460
|
-
|
|
2461
|
-
|
|
2462
|
-
|
|
2463
|
-
|
|
2464
|
-
|
|
2465
|
-
|
|
2466
|
-
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2515
|
+
function App() {
|
|
2516
|
+
return <>
|
|
2517
|
+
const boxSize: RippleObject<{ value: typeof mockBoxSize | null }> = new RippleObject({
|
|
2518
|
+
value: null,
|
|
2519
|
+
});
|
|
2520
|
+
effect(() => {
|
|
2521
|
+
if (boxSize.value) logs.push(boxSize.value);
|
|
2522
|
+
});
|
|
2523
|
+
<div
|
|
2524
|
+
ref={bindBorderBoxSize<null | typeof mockBoxSize>(
|
|
2525
|
+
() => boxSize.value,
|
|
2526
|
+
(v: typeof mockBoxSize) => (boxSize.value = v),
|
|
2527
|
+
)}
|
|
2528
|
+
/>
|
|
2529
|
+
</>;
|
|
2472
2530
|
}
|
|
2473
2531
|
|
|
2474
2532
|
render(App);
|
|
@@ -2490,14 +2548,14 @@ describe('bindDevicePixelContentBoxSize', () => {
|
|
|
2490
2548
|
it('should bind element devicePixelContentBoxSize', () => {
|
|
2491
2549
|
const logs: any[] = [];
|
|
2492
2550
|
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2499
|
-
|
|
2500
|
-
|
|
2551
|
+
function App() {
|
|
2552
|
+
return <>
|
|
2553
|
+
const boxSize = track(null);
|
|
2554
|
+
effect(() => {
|
|
2555
|
+
if (boxSize.value) logs.push(boxSize.value);
|
|
2556
|
+
});
|
|
2557
|
+
<div ref={bindDevicePixelContentBoxSize(boxSize)} />
|
|
2558
|
+
</>;
|
|
2501
2559
|
}
|
|
2502
2560
|
|
|
2503
2561
|
render(App);
|
|
@@ -2523,21 +2581,21 @@ describe('bindDevicePixelContentBoxSize', () => {
|
|
|
2523
2581
|
{ blockSize: 400, inlineSize: 600 },
|
|
2524
2582
|
];
|
|
2525
2583
|
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
value: null
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2584
|
+
function App() {
|
|
2585
|
+
return <>
|
|
2586
|
+
const boxSize: RippleObject<{ value: typeof mockBoxSize | null }> = new RippleObject({
|
|
2587
|
+
value: null,
|
|
2588
|
+
});
|
|
2589
|
+
effect(() => {
|
|
2590
|
+
if (boxSize.value) logs.push(boxSize.value);
|
|
2591
|
+
});
|
|
2592
|
+
<div
|
|
2593
|
+
ref={bindDevicePixelContentBoxSize<null | typeof mockBoxSize>(
|
|
2594
|
+
() => boxSize.value,
|
|
2595
|
+
(v: typeof mockBoxSize) => (boxSize.value = v),
|
|
2596
|
+
)}
|
|
2597
|
+
/>
|
|
2598
|
+
</>;
|
|
2541
2599
|
}
|
|
2542
2600
|
|
|
2543
2601
|
render(App);
|
|
@@ -2559,14 +2617,14 @@ describe('bindInnerHTML', () => {
|
|
|
2559
2617
|
it('should bind element innerHTML', () => {
|
|
2560
2618
|
const logs: string[] = [];
|
|
2561
2619
|
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2620
|
+
function App() {
|
|
2621
|
+
return <>
|
|
2622
|
+
const html = track('<strong>Hello</strong>');
|
|
2623
|
+
effect(() => {
|
|
2624
|
+
logs.push(html.value);
|
|
2625
|
+
});
|
|
2626
|
+
<div contenteditable="true" ref={bindInnerHTML(html)} />
|
|
2627
|
+
</>;
|
|
2570
2628
|
}
|
|
2571
2629
|
|
|
2572
2630
|
render(App);
|
|
@@ -2585,17 +2643,17 @@ describe('bindInnerHTML', () => {
|
|
|
2585
2643
|
it('should bind element innerHTML', () => {
|
|
2586
2644
|
const logs: string[] = [];
|
|
2587
2645
|
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2646
|
+
function App() {
|
|
2647
|
+
return <>
|
|
2648
|
+
const html = new RippleObject({ value: '<strong>Hello</strong>' });
|
|
2649
|
+
effect(() => {
|
|
2650
|
+
logs.push(html.value);
|
|
2651
|
+
});
|
|
2652
|
+
<div
|
|
2653
|
+
contenteditable="true"
|
|
2654
|
+
ref={bindInnerHTML(() => html.value, (v: string) => (html.value = v))}
|
|
2655
|
+
/>
|
|
2656
|
+
</>;
|
|
2599
2657
|
}
|
|
2600
2658
|
|
|
2601
2659
|
render(App);
|
|
@@ -2612,13 +2670,14 @@ describe('bindInnerHTML', () => {
|
|
|
2612
2670
|
});
|
|
2613
2671
|
|
|
2614
2672
|
it('should update innerHTML when tracked value changes', () => {
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2673
|
+
function App() {
|
|
2674
|
+
return <>
|
|
2675
|
+
const html = track('<p>Initial</p>');
|
|
2676
|
+
<div>
|
|
2677
|
+
<div contenteditable="true" ref={bindInnerHTML(html)} />
|
|
2678
|
+
<button onClick={() => (html.value = '<p>Updated</p>')}>{'Update'}</button>
|
|
2679
|
+
</div>
|
|
2680
|
+
</>;
|
|
2622
2681
|
}
|
|
2623
2682
|
|
|
2624
2683
|
render(App);
|
|
@@ -2636,16 +2695,17 @@ describe('bindInnerHTML', () => {
|
|
|
2636
2695
|
});
|
|
2637
2696
|
|
|
2638
2697
|
it('should update innerHTML when tracked value changes with a getter and setter', () => {
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2698
|
+
function App() {
|
|
2699
|
+
return <>
|
|
2700
|
+
const html = new RippleObject({ value: '<p>Initial</p>' });
|
|
2701
|
+
<div>
|
|
2702
|
+
<div
|
|
2703
|
+
contenteditable="true"
|
|
2704
|
+
ref={bindInnerHTML(() => html.value, (v: string) => (html.value = v))}
|
|
2705
|
+
/>
|
|
2706
|
+
<button onClick={() => (html.value = '<p>Updated</p>')}>{'Update'}</button>
|
|
2707
|
+
</div>
|
|
2708
|
+
</>;
|
|
2649
2709
|
}
|
|
2650
2710
|
|
|
2651
2711
|
render(App);
|
|
@@ -2663,10 +2723,11 @@ describe('bindInnerHTML', () => {
|
|
|
2663
2723
|
});
|
|
2664
2724
|
|
|
2665
2725
|
it('should handle null innerHTML value', () => {
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
|
|
2726
|
+
function App() {
|
|
2727
|
+
return <>
|
|
2728
|
+
const html = track(null);
|
|
2729
|
+
<div contenteditable="true" ref={bindInnerHTML(html)} />
|
|
2730
|
+
</>;
|
|
2670
2731
|
}
|
|
2671
2732
|
|
|
2672
2733
|
render(App);
|
|
@@ -2678,13 +2739,14 @@ describe('bindInnerHTML', () => {
|
|
|
2678
2739
|
});
|
|
2679
2740
|
|
|
2680
2741
|
it('should handle null innerHTML value with a getter and setter', () => {
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
|
|
2684
|
-
|
|
2685
|
-
|
|
2686
|
-
|
|
2687
|
-
|
|
2742
|
+
function App() {
|
|
2743
|
+
return <>
|
|
2744
|
+
const html: RippleObject<{ value: null | string }> = new RippleObject({ value: null });
|
|
2745
|
+
<div
|
|
2746
|
+
contenteditable="true"
|
|
2747
|
+
ref={bindInnerHTML(() => html.value, (v: string | null) => (html.value = v))}
|
|
2748
|
+
/>
|
|
2749
|
+
</>;
|
|
2688
2750
|
}
|
|
2689
2751
|
|
|
2690
2752
|
render(App);
|
|
@@ -2700,14 +2762,14 @@ describe('bindInnerText', () => {
|
|
|
2700
2762
|
it('should bind element innerText', () => {
|
|
2701
2763
|
const logs: string[] = [];
|
|
2702
2764
|
|
|
2703
|
-
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2765
|
+
function App() {
|
|
2766
|
+
return <>
|
|
2767
|
+
const text = track('Hello World');
|
|
2768
|
+
effect(() => {
|
|
2769
|
+
logs.push(text.value);
|
|
2770
|
+
});
|
|
2771
|
+
<div contenteditable="true" ref={bindInnerText(text)} />
|
|
2772
|
+
</>;
|
|
2711
2773
|
}
|
|
2712
2774
|
|
|
2713
2775
|
render(App);
|
|
@@ -2726,16 +2788,17 @@ describe('bindInnerText', () => {
|
|
|
2726
2788
|
it('should bind element innerText with a getter and setter', () => {
|
|
2727
2789
|
const logs: string[] = [];
|
|
2728
2790
|
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
|
|
2791
|
+
function App() {
|
|
2792
|
+
return <>
|
|
2793
|
+
const text = new RippleObject({ value: 'Hello World' });
|
|
2794
|
+
effect(() => {
|
|
2795
|
+
logs.push(text.value);
|
|
2796
|
+
});
|
|
2797
|
+
<div
|
|
2798
|
+
contenteditable="true"
|
|
2799
|
+
ref={bindInnerText(() => text.value, (v: string) => (text.value = v))}
|
|
2800
|
+
/>
|
|
2801
|
+
</>;
|
|
2739
2802
|
}
|
|
2740
2803
|
|
|
2741
2804
|
render(App);
|
|
@@ -2752,13 +2815,14 @@ describe('bindInnerText', () => {
|
|
|
2752
2815
|
});
|
|
2753
2816
|
|
|
2754
2817
|
it('should update innerText when tracked value changes', () => {
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
|
|
2818
|
+
function App() {
|
|
2819
|
+
return <>
|
|
2820
|
+
const text = track('Before');
|
|
2821
|
+
<div>
|
|
2822
|
+
<div contenteditable="true" ref={bindInnerText(text)} />
|
|
2823
|
+
<button onClick={() => (text.value = 'After')}>{'Update'}</button>
|
|
2824
|
+
</div>
|
|
2825
|
+
</>;
|
|
2762
2826
|
}
|
|
2763
2827
|
|
|
2764
2828
|
render(App);
|
|
@@ -2776,16 +2840,17 @@ describe('bindInnerText', () => {
|
|
|
2776
2840
|
});
|
|
2777
2841
|
|
|
2778
2842
|
it('should update innerText when tracked value changes with a getter and setter', () => {
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2843
|
+
function App() {
|
|
2844
|
+
return <>
|
|
2845
|
+
const text = new RippleObject({ value: 'Before' });
|
|
2846
|
+
<div>
|
|
2847
|
+
<div
|
|
2848
|
+
contenteditable="true"
|
|
2849
|
+
ref={bindInnerText(() => text.value, (v: string) => (text.value = v))}
|
|
2850
|
+
/>
|
|
2851
|
+
<button onClick={() => (text.value = 'After')}>{'Update'}</button>
|
|
2852
|
+
</div>
|
|
2853
|
+
</>;
|
|
2789
2854
|
}
|
|
2790
2855
|
|
|
2791
2856
|
render(App);
|
|
@@ -2807,14 +2872,14 @@ describe('bindTextContent', () => {
|
|
|
2807
2872
|
it('should bind element textContent', () => {
|
|
2808
2873
|
const logs: string[] = [];
|
|
2809
2874
|
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2815
|
-
|
|
2816
|
-
|
|
2817
|
-
|
|
2875
|
+
function App() {
|
|
2876
|
+
return <>
|
|
2877
|
+
const text = track('Sample text');
|
|
2878
|
+
effect(() => {
|
|
2879
|
+
logs.push(text.value);
|
|
2880
|
+
});
|
|
2881
|
+
<div contenteditable="true" ref={bindTextContent(text)} />
|
|
2882
|
+
</>;
|
|
2818
2883
|
}
|
|
2819
2884
|
|
|
2820
2885
|
render(App);
|
|
@@ -2833,17 +2898,17 @@ describe('bindTextContent', () => {
|
|
|
2833
2898
|
it('should bind element textContent with a getter and setter', () => {
|
|
2834
2899
|
const logs: string[] = [];
|
|
2835
2900
|
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2840
|
-
|
|
2841
|
-
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2901
|
+
function App() {
|
|
2902
|
+
return <>
|
|
2903
|
+
const text = new RippleObject({ value: 'Sample text' });
|
|
2904
|
+
effect(() => {
|
|
2905
|
+
logs.push(text.value);
|
|
2906
|
+
});
|
|
2907
|
+
<div
|
|
2908
|
+
contenteditable="true"
|
|
2909
|
+
ref={bindTextContent(() => text.value, (v: string) => (text.value = v))}
|
|
2910
|
+
/>
|
|
2911
|
+
</>;
|
|
2847
2912
|
}
|
|
2848
2913
|
|
|
2849
2914
|
render(App);
|
|
@@ -2860,13 +2925,14 @@ describe('bindTextContent', () => {
|
|
|
2860
2925
|
});
|
|
2861
2926
|
|
|
2862
2927
|
it('should update textContent when tracked value changes', () => {
|
|
2863
|
-
|
|
2864
|
-
|
|
2865
|
-
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2928
|
+
function App() {
|
|
2929
|
+
return <>
|
|
2930
|
+
const text = track('Start');
|
|
2931
|
+
<div>
|
|
2932
|
+
<div contenteditable="true" ref={bindTextContent(text)} />
|
|
2933
|
+
<button onClick={() => (text.value = 'End')}>{'Update'}</button>
|
|
2934
|
+
</div>
|
|
2935
|
+
</>;
|
|
2870
2936
|
}
|
|
2871
2937
|
|
|
2872
2938
|
render(App);
|
|
@@ -2884,16 +2950,17 @@ describe('bindTextContent', () => {
|
|
|
2884
2950
|
});
|
|
2885
2951
|
|
|
2886
2952
|
it('should update textContent when tracked value changes with a getter and setter', () => {
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2953
|
+
function App() {
|
|
2954
|
+
return <>
|
|
2955
|
+
const text = new RippleObject({ value: 'Start' });
|
|
2956
|
+
<div>
|
|
2957
|
+
<div
|
|
2958
|
+
contenteditable="true"
|
|
2959
|
+
ref={bindTextContent(() => text.value, (v: string) => (text.value = v))}
|
|
2960
|
+
/>
|
|
2961
|
+
<button onClick={() => (text.value = 'End')}>{'Update'}</button>
|
|
2962
|
+
</div>
|
|
2963
|
+
</>;
|
|
2897
2964
|
}
|
|
2898
2965
|
|
|
2899
2966
|
render(App);
|
|
@@ -2911,10 +2978,11 @@ describe('bindTextContent', () => {
|
|
|
2911
2978
|
});
|
|
2912
2979
|
|
|
2913
2980
|
it('should handle null textContent value', () => {
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2981
|
+
function App() {
|
|
2982
|
+
return <>
|
|
2983
|
+
const text = track(null);
|
|
2984
|
+
<div contenteditable="true" ref={bindTextContent(text)} />
|
|
2985
|
+
</>;
|
|
2918
2986
|
}
|
|
2919
2987
|
|
|
2920
2988
|
render(App);
|
|
@@ -2926,16 +2994,17 @@ describe('bindTextContent', () => {
|
|
|
2926
2994
|
});
|
|
2927
2995
|
|
|
2928
2996
|
it('should handle null textContent value with a getter and setter', () => {
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2997
|
+
function App() {
|
|
2998
|
+
return <>
|
|
2999
|
+
const text: RippleObject<{ value: string | null }> = new RippleObject({ value: null });
|
|
3000
|
+
<div
|
|
3001
|
+
contenteditable="true"
|
|
3002
|
+
ref={bindTextContent<string | null>(
|
|
3003
|
+
() => text.value,
|
|
3004
|
+
(v: string | null) => (text.value = v),
|
|
3005
|
+
)}
|
|
3006
|
+
/>
|
|
3007
|
+
</>;
|
|
2939
3008
|
}
|
|
2940
3009
|
|
|
2941
3010
|
render(App);
|
|
@@ -2951,14 +3020,14 @@ describe('bindNode', () => {
|
|
|
2951
3020
|
it('should update tracked value with element reference', () => {
|
|
2952
3021
|
let capturedNode: HTMLElement | null = null;
|
|
2953
3022
|
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
3023
|
+
function App() {
|
|
3024
|
+
return <>
|
|
3025
|
+
const nodeRef = track(null);
|
|
3026
|
+
effect(() => {
|
|
3027
|
+
capturedNode = nodeRef.value;
|
|
3028
|
+
});
|
|
3029
|
+
<div ref={bindNode(nodeRef)} />
|
|
3030
|
+
</>;
|
|
2962
3031
|
}
|
|
2963
3032
|
|
|
2964
3033
|
render(App);
|
|
@@ -2971,16 +3040,16 @@ describe('bindNode', () => {
|
|
|
2971
3040
|
it('should update tracked value with element reference and with a getter and setter', () => {
|
|
2972
3041
|
let capturedNode: HTMLElement | null = null;
|
|
2973
3042
|
|
|
2974
|
-
|
|
2975
|
-
|
|
2976
|
-
value: null
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
|
|
2981
|
-
|
|
2982
|
-
|
|
2983
|
-
|
|
3043
|
+
function App() {
|
|
3044
|
+
return <>
|
|
3045
|
+
const nodeRef: RippleObject<{ value: HTMLElement | null }> = new RippleObject({
|
|
3046
|
+
value: null,
|
|
3047
|
+
});
|
|
3048
|
+
effect(() => {
|
|
3049
|
+
capturedNode = nodeRef.value;
|
|
3050
|
+
});
|
|
3051
|
+
<div ref={bindNode(() => nodeRef.value, (v: HTMLElement | null) => (nodeRef.value = v))} />
|
|
3052
|
+
</>;
|
|
2984
3053
|
}
|
|
2985
3054
|
|
|
2986
3055
|
render(App);
|
|
@@ -2991,21 +3060,22 @@ describe('bindNode', () => {
|
|
|
2991
3060
|
});
|
|
2992
3061
|
|
|
2993
3062
|
it('should allow access to bound element', () => {
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3063
|
+
function App() {
|
|
3064
|
+
return <>
|
|
3065
|
+
const inputRef = track<HTMLInputElement | null>(null);
|
|
3066
|
+
<div>
|
|
3067
|
+
<input type="text" ref={bindNode(inputRef)} />
|
|
3068
|
+
<button
|
|
3069
|
+
onClick={() => {
|
|
3070
|
+
if (inputRef.value) {
|
|
3071
|
+
inputRef.value.value = 'Set by ref';
|
|
3072
|
+
}
|
|
3073
|
+
}}
|
|
3074
|
+
>
|
|
3075
|
+
{'Set Value'}
|
|
3076
|
+
</button>
|
|
3077
|
+
</div>
|
|
3078
|
+
</>;
|
|
3009
3079
|
}
|
|
3010
3080
|
|
|
3011
3081
|
render(App);
|
|
@@ -3023,26 +3093,27 @@ describe('bindNode', () => {
|
|
|
3023
3093
|
});
|
|
3024
3094
|
|
|
3025
3095
|
it('should allow access to bound element with a getter and setter', () => {
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
node: null
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3096
|
+
function App() {
|
|
3097
|
+
return <>
|
|
3098
|
+
const inputRef: RippleObject<{ node: HTMLInputElement | null }> = new RippleObject({
|
|
3099
|
+
node: null,
|
|
3100
|
+
});
|
|
3101
|
+
<div>
|
|
3102
|
+
<input
|
|
3103
|
+
type="text"
|
|
3104
|
+
ref={bindNode(() => inputRef.node, (v: HTMLInputElement | null) => (inputRef.node = v))}
|
|
3105
|
+
/>
|
|
3106
|
+
<button
|
|
3107
|
+
onClick={() => {
|
|
3108
|
+
if (inputRef.node) {
|
|
3109
|
+
inputRef.node.value = 'Set by ref';
|
|
3110
|
+
}
|
|
3111
|
+
}}
|
|
3112
|
+
>
|
|
3113
|
+
{'Set Value'}
|
|
3114
|
+
</button>
|
|
3115
|
+
</div>
|
|
3116
|
+
</>;
|
|
3046
3117
|
}
|
|
3047
3118
|
|
|
3048
3119
|
render(App);
|
|
@@ -3064,15 +3135,15 @@ describe('bindFiles', () => {
|
|
|
3064
3135
|
it('should bind files from file input', () => {
|
|
3065
3136
|
const logs: FileList[] = [];
|
|
3066
3137
|
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3138
|
+
function App() {
|
|
3139
|
+
return <>
|
|
3140
|
+
const files = track(null);
|
|
3141
|
+
effect(() => {
|
|
3142
|
+
files.value;
|
|
3143
|
+
if (files.value) logs.push(files.value);
|
|
3144
|
+
});
|
|
3145
|
+
<input type="file" multiple ref={bindFiles(files)} />
|
|
3146
|
+
</>;
|
|
3076
3147
|
}
|
|
3077
3148
|
|
|
3078
3149
|
render(App);
|
|
@@ -3105,19 +3176,19 @@ describe('bindFiles', () => {
|
|
|
3105
3176
|
it('should bind files from file input with a getter and setter', () => {
|
|
3106
3177
|
const logs: FileList[] = [];
|
|
3107
3178
|
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3179
|
+
function App() {
|
|
3180
|
+
return <>
|
|
3181
|
+
const files: RippleObject<{ items: FileList | null }> = new RippleObject({ items: null });
|
|
3182
|
+
effect(() => {
|
|
3183
|
+
files.items;
|
|
3184
|
+
if (files.items) logs.push(files.items);
|
|
3185
|
+
});
|
|
3186
|
+
<input
|
|
3187
|
+
type="file"
|
|
3188
|
+
multiple
|
|
3189
|
+
ref={bindFiles(() => files.items, (v: FileList | null) => (files.items = v))}
|
|
3190
|
+
/>
|
|
3191
|
+
</>;
|
|
3121
3192
|
}
|
|
3122
3193
|
|
|
3123
3194
|
render(App);
|
|
@@ -3150,14 +3221,14 @@ describe('bindFiles', () => {
|
|
|
3150
3221
|
it('should update tracked value when files are selected', () => {
|
|
3151
3222
|
let capturedFiles: FileList | null = null;
|
|
3152
3223
|
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3224
|
+
function App() {
|
|
3225
|
+
return <>
|
|
3226
|
+
const files = track<FileList | null>(null);
|
|
3227
|
+
effect(() => {
|
|
3228
|
+
capturedFiles = files.value;
|
|
3229
|
+
});
|
|
3230
|
+
<input type="file" ref={bindFiles(files)} />
|
|
3231
|
+
</>;
|
|
3161
3232
|
}
|
|
3162
3233
|
|
|
3163
3234
|
render(App);
|
|
@@ -3185,17 +3256,17 @@ describe('bindFiles', () => {
|
|
|
3185
3256
|
it('should update tracked value when files are selected with a getter and setter', () => {
|
|
3186
3257
|
let capturedFiles: FileList | null = null;
|
|
3187
3258
|
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3259
|
+
function App() {
|
|
3260
|
+
return <>
|
|
3261
|
+
const files: RippleObject<{ items: FileList | null }> = new RippleObject({ items: null });
|
|
3262
|
+
effect(() => {
|
|
3263
|
+
capturedFiles = files.items;
|
|
3264
|
+
});
|
|
3265
|
+
<input
|
|
3266
|
+
type="file"
|
|
3267
|
+
ref={bindFiles(() => files.items, (v: FileList | null) => (files.items = v))}
|
|
3268
|
+
/>
|
|
3269
|
+
</>;
|
|
3199
3270
|
}
|
|
3200
3271
|
|
|
3201
3272
|
render(App);
|
|
@@ -3223,27 +3294,27 @@ describe('bindFiles', () => {
|
|
|
3223
3294
|
it('should allow clearing files via input.files', () => {
|
|
3224
3295
|
let capturedFiles: FileList | null = null;
|
|
3225
3296
|
|
|
3226
|
-
|
|
3227
|
-
|
|
3228
|
-
|
|
3229
|
-
|
|
3230
|
-
|
|
3231
|
-
|
|
3232
|
-
|
|
3233
|
-
|
|
3234
|
-
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
|
|
3240
|
-
|
|
3241
|
-
}
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
</
|
|
3246
|
-
|
|
3297
|
+
function App() {
|
|
3298
|
+
return <>
|
|
3299
|
+
const files = track<FileList | null>(null);
|
|
3300
|
+
const input = track<HTMLInputElement | null>(null);
|
|
3301
|
+
effect(() => {
|
|
3302
|
+
capturedFiles = files.value;
|
|
3303
|
+
});
|
|
3304
|
+
<div>
|
|
3305
|
+
<input type="file" ref={bindFiles<FileList>(files)} ref={bindNode(input)} />
|
|
3306
|
+
<button
|
|
3307
|
+
onClick={() => {
|
|
3308
|
+
if (input.value) {
|
|
3309
|
+
input.value.files = new DataTransfer().files;
|
|
3310
|
+
input.value.dispatchEvent(new Event('change', { bubbles: true }));
|
|
3311
|
+
}
|
|
3312
|
+
}}
|
|
3313
|
+
>
|
|
3314
|
+
{'Clear'}
|
|
3315
|
+
</button>
|
|
3316
|
+
</div>
|
|
3317
|
+
</>;
|
|
3247
3318
|
}
|
|
3248
3319
|
|
|
3249
3320
|
render(App);
|
|
@@ -3276,31 +3347,31 @@ describe('bindFiles', () => {
|
|
|
3276
3347
|
it('should allow clearing files via input.files with a getter and setter', () => {
|
|
3277
3348
|
let capturedFiles: FileList | null = null;
|
|
3278
3349
|
|
|
3279
|
-
|
|
3280
|
-
|
|
3281
|
-
|
|
3282
|
-
|
|
3283
|
-
|
|
3284
|
-
|
|
3285
|
-
|
|
3286
|
-
|
|
3287
|
-
|
|
3288
|
-
|
|
3289
|
-
|
|
3290
|
-
|
|
3291
|
-
|
|
3292
|
-
|
|
3293
|
-
|
|
3294
|
-
|
|
3295
|
-
|
|
3296
|
-
|
|
3297
|
-
|
|
3298
|
-
}
|
|
3299
|
-
|
|
3300
|
-
|
|
3301
|
-
|
|
3302
|
-
</
|
|
3303
|
-
|
|
3350
|
+
function App() {
|
|
3351
|
+
return <>
|
|
3352
|
+
const files: RippleObject<{ items: FileList | null }> = new RippleObject({ items: null });
|
|
3353
|
+
const input = track<HTMLInputElement | null>(null);
|
|
3354
|
+
effect(() => {
|
|
3355
|
+
capturedFiles = files.items;
|
|
3356
|
+
});
|
|
3357
|
+
<div>
|
|
3358
|
+
<input
|
|
3359
|
+
type="file"
|
|
3360
|
+
ref={bindFiles(() => files.items, (v: FileList | null) => (files.items = v))}
|
|
3361
|
+
ref={bindNode(input)}
|
|
3362
|
+
/>
|
|
3363
|
+
<button
|
|
3364
|
+
onClick={() => {
|
|
3365
|
+
if (input.value) {
|
|
3366
|
+
input.value.files = new DataTransfer().files;
|
|
3367
|
+
input.value.dispatchEvent(new Event('change', { bubbles: true }));
|
|
3368
|
+
}
|
|
3369
|
+
}}
|
|
3370
|
+
>
|
|
3371
|
+
{'Clear'}
|
|
3372
|
+
</button>
|
|
3373
|
+
</div>
|
|
3374
|
+
</>;
|
|
3304
3375
|
}
|
|
3305
3376
|
|
|
3306
3377
|
render(App);
|
|
@@ -3333,17 +3404,17 @@ describe('bindFiles', () => {
|
|
|
3333
3404
|
it('should handle multiple file selections', () => {
|
|
3334
3405
|
const fileCounts: number[] = [];
|
|
3335
3406
|
|
|
3336
|
-
|
|
3337
|
-
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3342
|
-
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3407
|
+
function App() {
|
|
3408
|
+
return <>
|
|
3409
|
+
const files = track<FileList | null>(null);
|
|
3410
|
+
effect(() => {
|
|
3411
|
+
files.value;
|
|
3412
|
+
if (files.value) {
|
|
3413
|
+
fileCounts.push(files.value.length);
|
|
3414
|
+
}
|
|
3415
|
+
});
|
|
3416
|
+
<input type="file" multiple ref={bindFiles(files)} />
|
|
3417
|
+
</>;
|
|
3347
3418
|
}
|
|
3348
3419
|
|
|
3349
3420
|
render(App);
|
|
@@ -3382,20 +3453,21 @@ describe('bindFiles', () => {
|
|
|
3382
3453
|
it('should handle multiple file selections with a getter and setter', () => {
|
|
3383
3454
|
const fileCounts: number[] = [];
|
|
3384
3455
|
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3456
|
+
function App() {
|
|
3457
|
+
return <>
|
|
3458
|
+
const files: RippleObject<{ items: FileList | null }> = new RippleObject({ items: null });
|
|
3459
|
+
effect(() => {
|
|
3460
|
+
files.items;
|
|
3461
|
+
if (files.items) {
|
|
3462
|
+
fileCounts.push(files.items.length);
|
|
3463
|
+
}
|
|
3464
|
+
});
|
|
3465
|
+
<input
|
|
3466
|
+
type="file"
|
|
3467
|
+
multiple
|
|
3468
|
+
ref={bindFiles(() => files.items, (v: FileList | null) => (files.items = v))}
|
|
3469
|
+
/>
|
|
3470
|
+
</>;
|
|
3399
3471
|
}
|
|
3400
3472
|
|
|
3401
3473
|
render(App);
|
|
@@ -3434,17 +3506,17 @@ describe('bindFiles', () => {
|
|
|
3434
3506
|
it('should handle file input without multiple attribute', () => {
|
|
3435
3507
|
let capturedFile: File | null = null;
|
|
3436
3508
|
|
|
3437
|
-
|
|
3438
|
-
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
|
|
3509
|
+
function App() {
|
|
3510
|
+
return <>
|
|
3511
|
+
const files = track<FileList | null>(null);
|
|
3512
|
+
effect(() => {
|
|
3513
|
+
files.value;
|
|
3514
|
+
if (files.value && files.value.length > 0) {
|
|
3515
|
+
capturedFile = files.value[0];
|
|
3516
|
+
}
|
|
3517
|
+
});
|
|
3518
|
+
<input type="file" ref={bindFiles(files)} />
|
|
3519
|
+
</>;
|
|
3448
3520
|
}
|
|
3449
3521
|
|
|
3450
3522
|
render(App);
|
|
@@ -3471,19 +3543,20 @@ describe('bindFiles', () => {
|
|
|
3471
3543
|
it('should handle file input without multiple attribute with a getter and setter', () => {
|
|
3472
3544
|
let capturedFile: File | null = null;
|
|
3473
3545
|
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3546
|
+
function App() {
|
|
3547
|
+
return <>
|
|
3548
|
+
const files: RippleObject<{ items: FileList | null }> = new RippleObject({ items: null });
|
|
3549
|
+
effect(() => {
|
|
3550
|
+
files.items;
|
|
3551
|
+
if (files.items && files.items.length > 0) {
|
|
3552
|
+
capturedFile = files.items[0];
|
|
3553
|
+
}
|
|
3554
|
+
});
|
|
3555
|
+
<input
|
|
3556
|
+
type="file"
|
|
3557
|
+
ref={bindFiles(() => files.items, (v: FileList | null) => (files.items = v))}
|
|
3558
|
+
/>
|
|
3559
|
+
</>;
|
|
3487
3560
|
}
|
|
3488
3561
|
|
|
3489
3562
|
render(App);
|
|
@@ -3510,14 +3583,14 @@ describe('bindFiles', () => {
|
|
|
3510
3583
|
it('should handle empty file selection', () => {
|
|
3511
3584
|
const logs: (FileList | null)[] = [];
|
|
3512
3585
|
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3586
|
+
function App() {
|
|
3587
|
+
return <>
|
|
3588
|
+
const files = track(null);
|
|
3589
|
+
effect(() => {
|
|
3590
|
+
logs.push(files.value);
|
|
3591
|
+
});
|
|
3592
|
+
<input type="file" ref={bindFiles(files)} />
|
|
3593
|
+
</>;
|
|
3521
3594
|
}
|
|
3522
3595
|
|
|
3523
3596
|
render(App);
|
|
@@ -3552,16 +3625,17 @@ describe('bindFiles', () => {
|
|
|
3552
3625
|
it('should handle empty file selection with a getter and setter', () => {
|
|
3553
3626
|
const logs: (FileList | null)[] = [];
|
|
3554
3627
|
|
|
3555
|
-
|
|
3556
|
-
|
|
3557
|
-
|
|
3558
|
-
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
|
|
3563
|
-
|
|
3564
|
-
|
|
3628
|
+
function App() {
|
|
3629
|
+
return <>
|
|
3630
|
+
const files: RippleObject<{ items: FileList | null }> = new RippleObject({ items: null });
|
|
3631
|
+
effect(() => {
|
|
3632
|
+
logs.push(files.items);
|
|
3633
|
+
});
|
|
3634
|
+
<input
|
|
3635
|
+
type="file"
|
|
3636
|
+
ref={bindFiles(() => files.items, (v: FileList | null) => (files.items = v))}
|
|
3637
|
+
/>
|
|
3638
|
+
</>;
|
|
3565
3639
|
}
|
|
3566
3640
|
|
|
3567
3641
|
render(App);
|
|
@@ -3597,9 +3671,8 @@ describe('bindFiles', () => {
|
|
|
3597
3671
|
describe('error handling', () => {
|
|
3598
3672
|
it('should throw error when bindValue receives non-tracked object', () => {
|
|
3599
3673
|
expect(() => {
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
<input type="text" {ref bindValue({ value: 'not tracked' })} />
|
|
3674
|
+
function App() {
|
|
3675
|
+
return <><input type="text" ref={bindValue({ value: 'not tracked' })} /></>;
|
|
3603
3676
|
}
|
|
3604
3677
|
render(App);
|
|
3605
3678
|
}).toThrow('bindValue() argument is not a tracked object');
|
|
@@ -3607,9 +3680,8 @@ describe('error handling', () => {
|
|
|
3607
3680
|
|
|
3608
3681
|
it('should throw error when bindChecked receives non-tracked object', () => {
|
|
3609
3682
|
expect(() => {
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
<input type="checkbox" {ref bindChecked({ value: false })} />
|
|
3683
|
+
function App() {
|
|
3684
|
+
return <><input type="checkbox" ref={bindChecked({ value: false })} /></>;
|
|
3613
3685
|
}
|
|
3614
3686
|
render(App);
|
|
3615
3687
|
}).toThrow('bindChecked() argument is not a tracked object');
|
|
@@ -3617,9 +3689,8 @@ describe('error handling', () => {
|
|
|
3617
3689
|
|
|
3618
3690
|
it('should throw error when bindIndeterminate receives non-tracked object', () => {
|
|
3619
3691
|
expect(() => {
|
|
3620
|
-
|
|
3621
|
-
|
|
3622
|
-
<input type="checkbox" {ref bindIndeterminate({ value: false })} />
|
|
3692
|
+
function App() {
|
|
3693
|
+
return <><input type="checkbox" ref={bindIndeterminate({ value: false })} /></>;
|
|
3623
3694
|
}
|
|
3624
3695
|
render(App);
|
|
3625
3696
|
}).toThrow('bindIndeterminate() argument is not a tracked object');
|
|
@@ -3627,9 +3698,8 @@ describe('error handling', () => {
|
|
|
3627
3698
|
|
|
3628
3699
|
it('should throw error when bindGroup receives non-tracked object', () => {
|
|
3629
3700
|
expect(() => {
|
|
3630
|
-
|
|
3631
|
-
|
|
3632
|
-
<input type="checkbox" value="a" {ref bindGroup({ value: [] })} />
|
|
3701
|
+
function App() {
|
|
3702
|
+
return <><input type="checkbox" value="a" ref={bindGroup({ value: [] })} /></>;
|
|
3633
3703
|
}
|
|
3634
3704
|
render(App);
|
|
3635
3705
|
}).toThrow('bindGroup() argument is not a tracked object');
|
|
@@ -3637,9 +3707,8 @@ describe('error handling', () => {
|
|
|
3637
3707
|
|
|
3638
3708
|
it('should throw error when bindClientWidth receives non-tracked object', () => {
|
|
3639
3709
|
expect(() => {
|
|
3640
|
-
|
|
3641
|
-
|
|
3642
|
-
<div {ref bindClientWidth({ value: 0 })} />
|
|
3710
|
+
function App() {
|
|
3711
|
+
return <><div ref={bindClientWidth({ value: 0 })} /></>;
|
|
3643
3712
|
}
|
|
3644
3713
|
render(App);
|
|
3645
3714
|
}).toThrow('bindClientWidth() argument is not a tracked object');
|
|
@@ -3647,9 +3716,8 @@ describe('error handling', () => {
|
|
|
3647
3716
|
|
|
3648
3717
|
it('should throw error when bindClientHeight receives non-tracked object', () => {
|
|
3649
3718
|
expect(() => {
|
|
3650
|
-
|
|
3651
|
-
|
|
3652
|
-
<div {ref bindClientHeight({ value: 0 })} />
|
|
3719
|
+
function App() {
|
|
3720
|
+
return <><div ref={bindClientHeight({ value: 0 })} /></>;
|
|
3653
3721
|
}
|
|
3654
3722
|
render(App);
|
|
3655
3723
|
}).toThrow('bindClientHeight() argument is not a tracked object');
|
|
@@ -3657,9 +3725,8 @@ describe('error handling', () => {
|
|
|
3657
3725
|
|
|
3658
3726
|
it('should throw error when bindOffsetWidth receives non-tracked object', () => {
|
|
3659
3727
|
expect(() => {
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
<div {ref bindOffsetWidth({ value: 0 })} />
|
|
3728
|
+
function App() {
|
|
3729
|
+
return <><div ref={bindOffsetWidth({ value: 0 })} /></>;
|
|
3663
3730
|
}
|
|
3664
3731
|
render(App);
|
|
3665
3732
|
}).toThrow('bindOffsetWidth() argument is not a tracked object');
|
|
@@ -3667,9 +3734,8 @@ describe('error handling', () => {
|
|
|
3667
3734
|
|
|
3668
3735
|
it('should throw error when bindOffsetHeight receives non-tracked object', () => {
|
|
3669
3736
|
expect(() => {
|
|
3670
|
-
|
|
3671
|
-
|
|
3672
|
-
<div {ref bindOffsetHeight({ value: 0 })} />
|
|
3737
|
+
function App() {
|
|
3738
|
+
return <><div ref={bindOffsetHeight({ value: 0 })} /></>;
|
|
3673
3739
|
}
|
|
3674
3740
|
render(App);
|
|
3675
3741
|
}).toThrow('bindOffsetHeight() argument is not a tracked object');
|
|
@@ -3677,9 +3743,8 @@ describe('error handling', () => {
|
|
|
3677
3743
|
|
|
3678
3744
|
it('should throw error when bindContentRect receives non-tracked object', () => {
|
|
3679
3745
|
expect(() => {
|
|
3680
|
-
|
|
3681
|
-
|
|
3682
|
-
<div {ref bindContentRect({ value: null })} />
|
|
3746
|
+
function App() {
|
|
3747
|
+
return <><div ref={bindContentRect({ value: null })} /></>;
|
|
3683
3748
|
}
|
|
3684
3749
|
render(App);
|
|
3685
3750
|
}).toThrow('bindContentRect() argument is not a tracked object');
|
|
@@ -3687,9 +3752,8 @@ describe('error handling', () => {
|
|
|
3687
3752
|
|
|
3688
3753
|
it('should throw error when bindContentBoxSize receives non-tracked object', () => {
|
|
3689
3754
|
expect(() => {
|
|
3690
|
-
|
|
3691
|
-
|
|
3692
|
-
<div {ref bindContentBoxSize({ value: null })} />
|
|
3755
|
+
function App() {
|
|
3756
|
+
return <><div ref={bindContentBoxSize({ value: null })} /></>;
|
|
3693
3757
|
}
|
|
3694
3758
|
render(App);
|
|
3695
3759
|
}).toThrow('bindContentBoxSize() argument is not a tracked object');
|
|
@@ -3697,9 +3761,8 @@ describe('error handling', () => {
|
|
|
3697
3761
|
|
|
3698
3762
|
it('should throw error when bindBorderBoxSize receives non-tracked object', () => {
|
|
3699
3763
|
expect(() => {
|
|
3700
|
-
|
|
3701
|
-
|
|
3702
|
-
<div {ref bindBorderBoxSize({ value: null })} />
|
|
3764
|
+
function App() {
|
|
3765
|
+
return <><div ref={bindBorderBoxSize({ value: null })} /></>;
|
|
3703
3766
|
}
|
|
3704
3767
|
render(App);
|
|
3705
3768
|
}).toThrow('bindBorderBoxSize() argument is not a tracked object');
|
|
@@ -3707,9 +3770,8 @@ describe('error handling', () => {
|
|
|
3707
3770
|
|
|
3708
3771
|
it('should throw error when bindDevicePixelContentBoxSize receives non-tracked object', () => {
|
|
3709
3772
|
expect(() => {
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
<div {ref bindDevicePixelContentBoxSize({ value: null })} />
|
|
3773
|
+
function App() {
|
|
3774
|
+
return <><div ref={bindDevicePixelContentBoxSize({ value: null })} /></>;
|
|
3713
3775
|
}
|
|
3714
3776
|
render(App);
|
|
3715
3777
|
}).toThrow('bindDevicePixelContentBoxSize() argument is not a tracked object');
|
|
@@ -3717,9 +3779,8 @@ describe('error handling', () => {
|
|
|
3717
3779
|
|
|
3718
3780
|
it('should throw error when bindInnerHTML receives non-tracked object', () => {
|
|
3719
3781
|
expect(() => {
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
<div {ref bindInnerHTML({ value: '' })} />
|
|
3782
|
+
function App() {
|
|
3783
|
+
return <><div ref={bindInnerHTML({ value: '' })} /></>;
|
|
3723
3784
|
}
|
|
3724
3785
|
render(App);
|
|
3725
3786
|
}).toThrow('bindInnerHTML() argument is not a tracked object');
|
|
@@ -3727,9 +3788,8 @@ describe('error handling', () => {
|
|
|
3727
3788
|
|
|
3728
3789
|
it('should throw error when bindInnerText receives non-tracked object', () => {
|
|
3729
3790
|
expect(() => {
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
<div {ref bindInnerText({ value: '' })} />
|
|
3791
|
+
function App() {
|
|
3792
|
+
return <><div ref={bindInnerText({ value: '' })} /></>;
|
|
3733
3793
|
}
|
|
3734
3794
|
render(App);
|
|
3735
3795
|
}).toThrow('bindInnerText() argument is not a tracked object');
|
|
@@ -3737,9 +3797,8 @@ describe('error handling', () => {
|
|
|
3737
3797
|
|
|
3738
3798
|
it('should throw error when bindTextContent receives non-tracked object', () => {
|
|
3739
3799
|
expect(() => {
|
|
3740
|
-
|
|
3741
|
-
|
|
3742
|
-
<div {ref bindTextContent({ value: '' })} />
|
|
3800
|
+
function App() {
|
|
3801
|
+
return <><div ref={bindTextContent({ value: '' })} /></>;
|
|
3743
3802
|
}
|
|
3744
3803
|
render(App);
|
|
3745
3804
|
}).toThrow('bindTextContent() argument is not a tracked object');
|
|
@@ -3747,9 +3806,8 @@ describe('error handling', () => {
|
|
|
3747
3806
|
|
|
3748
3807
|
it('should throw error when bindNode receives non-tracked object', () => {
|
|
3749
3808
|
expect(() => {
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
<div {ref bindNode({ value: null })} />
|
|
3809
|
+
function App() {
|
|
3810
|
+
return <><div ref={bindNode({ value: null })} /></>;
|
|
3753
3811
|
}
|
|
3754
3812
|
render(App);
|
|
3755
3813
|
}).toThrow('bindNode() argument is not a tracked object');
|
|
@@ -3757,9 +3815,8 @@ describe('error handling', () => {
|
|
|
3757
3815
|
|
|
3758
3816
|
it('should throw error when bindFiles receives non-tracked object', () => {
|
|
3759
3817
|
expect(() => {
|
|
3760
|
-
|
|
3761
|
-
|
|
3762
|
-
<input type="file" {ref bindFiles({ value: null })} />
|
|
3818
|
+
function App() {
|
|
3819
|
+
return <><input type="file" ref={bindFiles({ value: null })} /></>;
|
|
3763
3820
|
}
|
|
3764
3821
|
render(App);
|
|
3765
3822
|
}).toThrow('bindFiles() argument is not a tracked object');
|
|
@@ -3767,9 +3824,11 @@ describe('error handling', () => {
|
|
|
3767
3824
|
|
|
3768
3825
|
it('should throw error when bindValue receives a getter but not a setter', () => {
|
|
3769
3826
|
expect(() => {
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3827
|
+
function App() {
|
|
3828
|
+
return <>
|
|
3829
|
+
const value = track('');
|
|
3830
|
+
<input type="text" ref={bindValue(() => value.value)} />
|
|
3831
|
+
</>;
|
|
3773
3832
|
}
|
|
3774
3833
|
render(App);
|
|
3775
3834
|
}).toThrow(
|
|
@@ -3779,10 +3838,12 @@ describe('error handling', () => {
|
|
|
3779
3838
|
|
|
3780
3839
|
it('should throw error when bindValue receives a getter and setter not a function', () => {
|
|
3781
3840
|
expect(() => {
|
|
3782
|
-
|
|
3783
|
-
|
|
3784
|
-
|
|
3785
|
-
|
|
3841
|
+
function App() {
|
|
3842
|
+
return <>
|
|
3843
|
+
const value = track('');
|
|
3844
|
+
// @ts-expect-error invalid argument
|
|
3845
|
+
<input type="text" ref={bindValue(() => value.value, 5)} />
|
|
3846
|
+
</>;
|
|
3786
3847
|
}
|
|
3787
3848
|
render(App);
|
|
3788
3849
|
}).toThrow(
|
|
@@ -3794,13 +3855,14 @@ describe('error handling', () => {
|
|
|
3794
3855
|
'should throw error when bindValue on select multiple receives a non-array tracked value',
|
|
3795
3856
|
() => {
|
|
3796
3857
|
expect(() => {
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3858
|
+
function App() {
|
|
3859
|
+
return <>
|
|
3860
|
+
const value = track('2');
|
|
3861
|
+
<select multiple ref={bindValue(value)}>
|
|
3862
|
+
<option value="1">{'One'}</option>
|
|
3863
|
+
<option value="2">{'Two'}</option>
|
|
3864
|
+
</select>
|
|
3865
|
+
</>;
|
|
3804
3866
|
}
|
|
3805
3867
|
|
|
3806
3868
|
render(App);
|
|
@@ -3815,13 +3877,14 @@ describe('error handling', () => {
|
|
|
3815
3877
|
'should throw error when bindValue on select multiple receives a non-array getter value',
|
|
3816
3878
|
() => {
|
|
3817
3879
|
expect(() => {
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3880
|
+
function App() {
|
|
3881
|
+
return <>
|
|
3882
|
+
const value = track('2');
|
|
3883
|
+
<select multiple ref={bindValue(() => value.value, (v) => (value.value = v))}>
|
|
3884
|
+
<option value="1">{'One'}</option>
|
|
3885
|
+
<option value="2">{'Two'}</option>
|
|
3886
|
+
</select>
|
|
3887
|
+
</>;
|
|
3825
3888
|
}
|
|
3826
3889
|
|
|
3827
3890
|
render(App);
|
|
@@ -3836,8 +3899,8 @@ describe('error handling', () => {
|
|
|
3836
3899
|
'should throw error when bindChecked receives non-tracked object with a getter but not a setter',
|
|
3837
3900
|
() => {
|
|
3838
3901
|
expect(() => {
|
|
3839
|
-
|
|
3840
|
-
|
|
3902
|
+
function App() {
|
|
3903
|
+
return <><input type="checkbox" ref={bindChecked(() => false)} /></>;
|
|
3841
3904
|
}
|
|
3842
3905
|
render(App);
|
|
3843
3906
|
}).toThrow(
|
|
@@ -3850,9 +3913,8 @@ describe('error handling', () => {
|
|
|
3850
3913
|
'should throw error when bindChecked receives non-tracked object with a getter and setter not a function',
|
|
3851
3914
|
() => {
|
|
3852
3915
|
expect(() => {
|
|
3853
|
-
|
|
3854
|
-
|
|
3855
|
-
<input type="checkbox" {ref bindChecked(() => false, true)} />
|
|
3916
|
+
function App() {
|
|
3917
|
+
return <><input type="checkbox" ref={bindChecked(() => false, true)} /></>;
|
|
3856
3918
|
}
|
|
3857
3919
|
render(App);
|
|
3858
3920
|
}).toThrow(
|
|
@@ -3865,9 +3927,8 @@ describe('error handling', () => {
|
|
|
3865
3927
|
'should throw error when bindIndeterminate receives non-tracked object with a getter and setter not a function',
|
|
3866
3928
|
() => {
|
|
3867
3929
|
expect(() => {
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
<input type="checkbox" {ref bindIndeterminate(() => false, true)} />
|
|
3930
|
+
function App() {
|
|
3931
|
+
return <><input type="checkbox" ref={bindIndeterminate(() => false, true)} /></>;
|
|
3871
3932
|
}
|
|
3872
3933
|
render(App);
|
|
3873
3934
|
}).toThrow(
|
|
@@ -3880,9 +3941,8 @@ describe('error handling', () => {
|
|
|
3880
3941
|
'should throw error when bindGroup receives non-tracked object with a getter and setter not a function',
|
|
3881
3942
|
() => {
|
|
3882
3943
|
expect(() => {
|
|
3883
|
-
|
|
3884
|
-
|
|
3885
|
-
<input type="checkbox" value="a" {ref bindGroup(() => [], true)} />
|
|
3944
|
+
function App() {
|
|
3945
|
+
return <><input type="checkbox" value="a" ref={bindGroup(() => [], true)} /></>;
|
|
3886
3946
|
}
|
|
3887
3947
|
render(App);
|
|
3888
3948
|
}).toThrow(
|
|
@@ -3895,9 +3955,8 @@ describe('error handling', () => {
|
|
|
3895
3955
|
'should throw error when bindClientWidth receives non-tracked object with a getter and setter not a function',
|
|
3896
3956
|
() => {
|
|
3897
3957
|
expect(() => {
|
|
3898
|
-
|
|
3899
|
-
|
|
3900
|
-
<div {ref bindClientWidth(() => 0, true)} />
|
|
3958
|
+
function App() {
|
|
3959
|
+
return <><div ref={bindClientWidth(() => 0, true)} /></>;
|
|
3901
3960
|
}
|
|
3902
3961
|
render(App);
|
|
3903
3962
|
}).toThrow(
|
|
@@ -3910,9 +3969,8 @@ describe('error handling', () => {
|
|
|
3910
3969
|
'should throw error when bindClientHeight receives non-tracked object with a getter and setter not a function',
|
|
3911
3970
|
() => {
|
|
3912
3971
|
expect(() => {
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
<div {ref bindClientHeight(() => 0, true)} />
|
|
3972
|
+
function App() {
|
|
3973
|
+
return <><div ref={bindClientHeight(() => 0, true)} /></>;
|
|
3916
3974
|
}
|
|
3917
3975
|
render(App);
|
|
3918
3976
|
}).toThrow(
|
|
@@ -3925,9 +3983,8 @@ describe('error handling', () => {
|
|
|
3925
3983
|
'should throw error when bindOffsetWidth receives non-tracked object with a getter and setter not a function',
|
|
3926
3984
|
() => {
|
|
3927
3985
|
expect(() => {
|
|
3928
|
-
|
|
3929
|
-
|
|
3930
|
-
<div {ref bindOffsetWidth(() => 0, true)} />
|
|
3986
|
+
function App() {
|
|
3987
|
+
return <><div ref={bindOffsetWidth(() => 0, true)} /></>;
|
|
3931
3988
|
}
|
|
3932
3989
|
render(App);
|
|
3933
3990
|
}).toThrow(
|
|
@@ -3940,9 +3997,8 @@ describe('error handling', () => {
|
|
|
3940
3997
|
'should throw error when bindOffsetHeight receives non-tracked object with a getter and setter not a function',
|
|
3941
3998
|
() => {
|
|
3942
3999
|
expect(() => {
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
<div {ref bindOffsetHeight(() => 0, true)} />
|
|
4000
|
+
function App() {
|
|
4001
|
+
return <><div ref={bindOffsetHeight(() => 0, true)} /></>;
|
|
3946
4002
|
}
|
|
3947
4003
|
render(App);
|
|
3948
4004
|
}).toThrow(
|
|
@@ -3955,9 +4011,8 @@ describe('error handling', () => {
|
|
|
3955
4011
|
'should throw error when bindContentRect receives non-tracked object with a getter and setter not a function',
|
|
3956
4012
|
() => {
|
|
3957
4013
|
expect(() => {
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
<div {ref bindContentRect(() => null, true)} />
|
|
4014
|
+
function App() {
|
|
4015
|
+
return <><div ref={bindContentRect(() => null, true)} /></>;
|
|
3961
4016
|
}
|
|
3962
4017
|
render(App);
|
|
3963
4018
|
}).toThrow(
|
|
@@ -3970,9 +4025,8 @@ describe('error handling', () => {
|
|
|
3970
4025
|
'should throw error when bindContentBoxSize receives non-tracked object with a getter and setter not a function',
|
|
3971
4026
|
() => {
|
|
3972
4027
|
expect(() => {
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
<div {ref bindContentBoxSize(() => null, true)} />
|
|
4028
|
+
function App() {
|
|
4029
|
+
return <><div ref={bindContentBoxSize(() => null, true)} /></>;
|
|
3976
4030
|
}
|
|
3977
4031
|
render(App);
|
|
3978
4032
|
}).toThrow(
|
|
@@ -3985,9 +4039,8 @@ describe('error handling', () => {
|
|
|
3985
4039
|
'should throw error when bindBorderBoxSize receives non-tracked object with a getter and setter not a function',
|
|
3986
4040
|
() => {
|
|
3987
4041
|
expect(() => {
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
<div {ref bindBorderBoxSize(() => null, true)} />
|
|
4042
|
+
function App() {
|
|
4043
|
+
return <><div ref={bindBorderBoxSize(() => null, true)} /></>;
|
|
3991
4044
|
}
|
|
3992
4045
|
render(App);
|
|
3993
4046
|
}).toThrow(
|
|
@@ -4000,9 +4053,8 @@ describe('error handling', () => {
|
|
|
4000
4053
|
'should throw error when bindDevicePixelContentBoxSize receives non-tracked object with a getter and setter not a function',
|
|
4001
4054
|
() => {
|
|
4002
4055
|
expect(() => {
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
<div {ref bindDevicePixelContentBoxSize(() => null, true)} />
|
|
4056
|
+
function App() {
|
|
4057
|
+
return <><div ref={bindDevicePixelContentBoxSize(() => null, true)} /></>;
|
|
4006
4058
|
}
|
|
4007
4059
|
render(App);
|
|
4008
4060
|
}).toThrow(
|
|
@@ -4015,9 +4067,8 @@ describe('error handling', () => {
|
|
|
4015
4067
|
'should throw error when bindInnerHTML receives non-tracked object with a getter and setter not a function',
|
|
4016
4068
|
() => {
|
|
4017
4069
|
expect(() => {
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
<div {ref bindInnerHTML(() => '', true)} />
|
|
4070
|
+
function App() {
|
|
4071
|
+
return <><div ref={bindInnerHTML(() => '', true)} /></>;
|
|
4021
4072
|
}
|
|
4022
4073
|
render(App);
|
|
4023
4074
|
}).toThrow(
|
|
@@ -4030,9 +4081,8 @@ describe('error handling', () => {
|
|
|
4030
4081
|
'should throw error when bindInnerText receives non-tracked object with a getter and setter not a function',
|
|
4031
4082
|
() => {
|
|
4032
4083
|
expect(() => {
|
|
4033
|
-
|
|
4034
|
-
|
|
4035
|
-
<div {ref bindInnerText(() => '', true)} />
|
|
4084
|
+
function App() {
|
|
4085
|
+
return <><div ref={bindInnerText(() => '', true)} /></>;
|
|
4036
4086
|
}
|
|
4037
4087
|
render(App);
|
|
4038
4088
|
}).toThrow(
|
|
@@ -4045,9 +4095,8 @@ describe('error handling', () => {
|
|
|
4045
4095
|
'should throw error when bindTextContent receives non-tracked object with a getter and setter not a function',
|
|
4046
4096
|
() => {
|
|
4047
4097
|
expect(() => {
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
<div {ref bindTextContent(() => '', true)} />
|
|
4098
|
+
function App() {
|
|
4099
|
+
return <><div ref={bindTextContent(() => '', true)} /></>;
|
|
4051
4100
|
}
|
|
4052
4101
|
render(App);
|
|
4053
4102
|
}).toThrow(
|
|
@@ -4060,9 +4109,8 @@ describe('error handling', () => {
|
|
|
4060
4109
|
'should throw error when bindNode receives non-tracked object with a getter and setter not a function',
|
|
4061
4110
|
() => {
|
|
4062
4111
|
expect(() => {
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
<div {ref bindNode(() => null, true)} />
|
|
4112
|
+
function App() {
|
|
4113
|
+
return <><div ref={bindNode(() => null, true)} /></>;
|
|
4066
4114
|
}
|
|
4067
4115
|
render(App);
|
|
4068
4116
|
}).toThrow(
|
|
@@ -4075,9 +4123,8 @@ describe('error handling', () => {
|
|
|
4075
4123
|
'should throw error when bindFiles receives non-tracked object with a getter and setter not a function',
|
|
4076
4124
|
() => {
|
|
4077
4125
|
expect(() => {
|
|
4078
|
-
|
|
4079
|
-
|
|
4080
|
-
<input type="file" {ref bindFiles(() => null, true)} />
|
|
4126
|
+
function App() {
|
|
4127
|
+
return <><input type="file" ref={bindFiles(() => null, true)} /></>;
|
|
4081
4128
|
}
|
|
4082
4129
|
render(App);
|
|
4083
4130
|
}).toThrow(
|