ripple 0.3.71 → 0.3.74
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 +75 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +2 -8
- package/src/runtime/index-client.js +3 -13
- package/src/runtime/internal/client/blocks.js +3 -25
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
- package/tests/client/array/array.copy-within.test.tsrx +19 -19
- package/tests/client/array/array.derived.test.tsrx +97 -109
- package/tests/client/array/array.iteration.test.tsrx +28 -28
- package/tests/client/array/array.mutations.test.tsrx +68 -68
- package/tests/client/array/array.static.test.tsrx +82 -92
- package/tests/client/array/array.to-methods.test.tsrx +15 -15
- package/tests/client/async-suspend.test.tsrx +180 -179
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
- package/tests/client/basic/basic.attributes.test.tsrx +273 -317
- package/tests/client/basic/basic.collections.test.tsrx +59 -71
- package/tests/client/basic/basic.components.test.tsrx +196 -222
- package/tests/client/basic/basic.errors.test.tsrx +72 -78
- package/tests/client/basic/basic.events.test.tsrx +80 -85
- package/tests/client/basic/basic.get-set.test.tsrx +54 -64
- package/tests/client/basic/basic.hmr.test.tsrx +15 -19
- package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
- package/tests/client/basic/basic.rendering.test.tsrx +273 -178
- package/tests/client/basic/basic.utilities.test.tsrx +8 -10
- package/tests/client/boundaries.test.tsrx +18 -18
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
- package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
- package/tests/client/compiler/compiler.basic.test.tsrx +364 -296
- package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
- package/tests/client/composite/composite.dynamic-components.test.tsrx +41 -44
- package/tests/client/composite/composite.generics.test.tsrx +165 -167
- package/tests/client/composite/composite.props.test.tsrx +66 -74
- package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
- package/tests/client/composite/composite.render.test.tsrx +92 -101
- package/tests/client/computed-properties.test.tsrx +14 -18
- package/tests/client/context.test.tsrx +14 -18
- package/tests/client/css/global-additional-cases.test.tsrx +491 -437
- package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
- package/tests/client/css/global-at-rules.test.tsrx +71 -66
- package/tests/client/css/global-basic.test.tsrx +105 -98
- package/tests/client/css/global-classes-ids.test.tsrx +128 -114
- package/tests/client/css/global-combinators.test.tsrx +83 -78
- package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
- package/tests/client/css/global-edge-cases.test.tsrx +138 -120
- package/tests/client/css/global-keyframes.test.tsrx +108 -96
- package/tests/client/css/global-nested.test.tsrx +88 -78
- package/tests/client/css/global-pseudo.test.tsrx +104 -98
- package/tests/client/css/global-scoping.test.tsrx +145 -125
- package/tests/client/css/style-identifier.test.tsrx +62 -69
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +227 -283
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +40 -48
- package/tests/client/html.test.tsrx +37 -49
- package/tests/client/input-value.test.tsrx +1125 -1354
- package/tests/client/lazy-array.test.tsrx +10 -16
- package/tests/client/lazy-destructuring.test.tsrx +169 -221
- package/tests/client/map.test.tsrx +39 -41
- package/tests/client/media-query.test.tsrx +15 -19
- package/tests/client/object.test.tsrx +46 -56
- package/tests/client/portal.test.tsrx +31 -37
- package/tests/client/ref.test.tsrx +173 -193
- package/tests/client/return.test.tsrx +62 -37
- package/tests/client/set.test.tsrx +33 -33
- package/tests/client/svg.test.tsrx +195 -215
- package/tests/client/switch.test.tsrx +201 -191
- package/tests/client/track-async-hydration.test.tsrx +14 -18
- package/tests/client/tracked-index-access.test.tsrx +18 -28
- package/tests/client/try.test.tsrx +494 -619
- package/tests/client/tsx.test.tsrx +290 -371
- package/tests/client/typescript-generics.test.tsrx +121 -129
- package/tests/client/url/url.derived.test.tsrx +21 -25
- package/tests/client/url/url.parsing.test.tsrx +35 -35
- package/tests/client/url/url.partial-removal.test.tsrx +32 -32
- package/tests/client/url/url.reactivity.test.tsrx +68 -72
- package/tests/client/url/url.serialization.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
- package/tests/hydration/compiled/client/basic.js +396 -325
- package/tests/hydration/compiled/client/composite.js +52 -44
- package/tests/hydration/compiled/client/for.js +734 -604
- package/tests/hydration/compiled/client/head.js +183 -103
- package/tests/hydration/compiled/client/html.js +93 -86
- package/tests/hydration/compiled/client/if-children.js +95 -71
- package/tests/hydration/compiled/client/if.js +113 -89
- package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
- package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
- package/tests/hydration/compiled/client/reactivity.js +26 -24
- package/tests/hydration/compiled/client/return.js +8 -42
- package/tests/hydration/compiled/client/switch.js +208 -173
- package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
- package/tests/hydration/compiled/client/try.js +29 -21
- package/tests/hydration/compiled/server/basic.js +210 -221
- package/tests/hydration/compiled/server/composite.js +13 -14
- package/tests/hydration/compiled/server/for.js +427 -444
- package/tests/hydration/compiled/server/head.js +199 -189
- package/tests/hydration/compiled/server/html.js +33 -41
- package/tests/hydration/compiled/server/if-children.js +114 -117
- package/tests/hydration/compiled/server/if.js +77 -83
- package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
- package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
- package/tests/hydration/compiled/server/reactivity.js +24 -22
- package/tests/hydration/compiled/server/return.js +6 -18
- package/tests/hydration/compiled/server/switch.js +179 -176
- package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
- package/tests/hydration/compiled/server/try.js +31 -35
- package/tests/hydration/components/basic.tsrx +216 -286
- package/tests/hydration/components/composite.tsrx +32 -42
- package/tests/hydration/components/events.tsrx +81 -101
- package/tests/hydration/components/for.tsrx +270 -336
- package/tests/hydration/components/head.tsrx +43 -39
- package/tests/hydration/components/hmr.tsrx +16 -22
- package/tests/hydration/components/html-in-template.tsrx +15 -21
- package/tests/hydration/components/html.tsrx +442 -526
- package/tests/hydration/components/if-children.tsrx +107 -125
- package/tests/hydration/components/if.tsrx +68 -90
- package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
- package/tests/hydration/components/nested-control-flow.tsrx +202 -216
- package/tests/hydration/components/portal.tsrx +33 -41
- package/tests/hydration/components/reactivity.tsrx +26 -34
- package/tests/hydration/components/return.tsrx +4 -6
- package/tests/hydration/components/switch.tsrx +73 -78
- package/tests/hydration/components/track-async-serialization.tsrx +83 -93
- package/tests/hydration/components/try.tsrx +37 -51
- package/tests/hydration/switch.test.js +8 -8
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +120 -167
- package/tests/server/basic.components.test.tsrx +163 -197
- package/tests/server/basic.test.tsrx +298 -220
- package/tests/server/compiler.test.tsrx +142 -72
- package/tests/server/composite.props.test.tsrx +54 -58
- package/tests/server/composite.test.tsrx +165 -167
- package/tests/server/context.test.tsrx +13 -17
- package/tests/server/dynamic-elements.test.tsrx +103 -135
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +31 -31
- package/tests/server/html-nesting-validation.test.tsrx +16 -8
- package/tests/server/if.test.tsrx +49 -59
- package/tests/server/lazy-destructuring.test.tsrx +288 -366
- package/tests/server/return.test.tsrx +58 -36
- package/tests/server/streaming-ssr.test.tsrx +4 -4
- package/tests/server/style-identifier.test.tsrx +58 -66
- package/tests/server/switch.test.tsrx +89 -97
- package/tests/server/track-async-serialization.test.tsrx +85 -103
- package/tests/server/try.test.tsrx +275 -360
- package/tests/utils/ref-types.test.js +72 -0
- package/tests/utils/vite-plugin-config.test.js +41 -74
- package/types/index.d.ts +1 -0
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -2,13 +2,13 @@ import { RippleURL, RippleURLSearchParams, flushSync, track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('RippleURLSearchParams > iteration', () => {
|
|
4
4
|
it('handles keys method with reactivity', () => {
|
|
5
|
-
function URLTest() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function URLTest() @{
|
|
6
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
7
|
+
let &[keys] = track(() => Array.from(params.keys()));
|
|
8
|
+
<>
|
|
9
9
|
<button onClick={() => params.append('new', 'value')}>{'add param'}</button>
|
|
10
10
|
<pre>{JSON.stringify(keys)}</pre>
|
|
11
|
-
|
|
11
|
+
</>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
render(URLTest);
|
|
@@ -26,13 +26,13 @@ describe('RippleURLSearchParams > iteration', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('handles values method with reactivity', () => {
|
|
29
|
-
function URLTest() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
function URLTest() @{
|
|
30
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
31
|
+
let &[values] = track(() => Array.from(params.values()));
|
|
32
|
+
<>
|
|
33
33
|
<button onClick={() => params.set('foo', 'updated')}>{'update foo'}</button>
|
|
34
34
|
<pre>{JSON.stringify(values)}</pre>
|
|
35
|
-
|
|
35
|
+
</>
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
render(URLTest);
|
|
@@ -50,13 +50,13 @@ describe('RippleURLSearchParams > iteration', () => {
|
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
it('handles entries method with reactivity', () => {
|
|
53
|
-
function URLTest() {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
function URLTest() @{
|
|
54
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
55
|
+
let &[entries] = track(() => Array.from(params.entries()));
|
|
56
|
+
<>
|
|
57
57
|
<button onClick={() => params.append('new', 'value')}>{'add param'}</button>
|
|
58
58
|
<pre>{JSON.stringify(entries)}</pre>
|
|
59
|
-
|
|
59
|
+
</>
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
render(URLTest);
|
|
@@ -76,13 +76,13 @@ describe('RippleURLSearchParams > iteration', () => {
|
|
|
76
76
|
});
|
|
77
77
|
|
|
78
78
|
it('handles Symbol.iterator with reactivity', () => {
|
|
79
|
-
function URLTest() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
79
|
+
function URLTest() @{
|
|
80
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
81
|
+
let &[entries] = track(() => Array.from(params));
|
|
82
|
+
<>
|
|
83
83
|
<button onClick={() => params.delete('foo')}>{'delete foo'}</button>
|
|
84
84
|
<pre>{JSON.stringify(entries)}</pre>
|
|
85
|
-
|
|
85
|
+
</>
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
render(URLTest);
|
|
@@ -100,14 +100,14 @@ describe('RippleURLSearchParams > iteration', () => {
|
|
|
100
100
|
});
|
|
101
101
|
|
|
102
102
|
it('handles iteration with for...of', () => {
|
|
103
|
-
function URLTest() {
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
function URLTest() @{
|
|
104
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
105
|
+
<>
|
|
106
106
|
<button onClick={() => params.append('new', 'value')}>{'add param'}</button>
|
|
107
|
-
for (const [key, value] of params) {
|
|
107
|
+
@for (const [key, value] of params) {
|
|
108
108
|
<pre>{`${key}=${value}`}</pre>
|
|
109
109
|
}
|
|
110
|
-
|
|
110
|
+
</>
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
render(URLTest);
|
|
@@ -128,20 +128,20 @@ describe('RippleURLSearchParams > iteration', () => {
|
|
|
128
128
|
});
|
|
129
129
|
|
|
130
130
|
it('handles forEach iteration', () => {
|
|
131
|
-
function URLTest() {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
let
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
131
|
+
function URLTest() @{
|
|
132
|
+
const params = RippleURLSearchParams('a=1&b=2&c=3');
|
|
133
|
+
let &[sum] = track(() => {
|
|
134
|
+
let total = 0;
|
|
135
|
+
// Access the params reactively through entries
|
|
136
|
+
for (const [key, value] of params.entries()) {
|
|
137
|
+
total += parseInt(value, 10);
|
|
138
|
+
}
|
|
139
|
+
return total;
|
|
140
|
+
});
|
|
141
|
+
<>
|
|
142
142
|
<button onClick={() => params.append('d', '4')}>{'add d=4'}</button>
|
|
143
143
|
<pre>{sum}</pre>
|
|
144
|
-
|
|
144
|
+
</>
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
render(URLTest);
|
|
@@ -2,13 +2,13 @@ import { RippleURL, RippleURLSearchParams, flushSync, track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('RippleURLSearchParams > mutation', () => {
|
|
4
4
|
it('handles append operation with reactivity', () => {
|
|
5
|
-
function URLTest() {
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
function URLTest() @{
|
|
6
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
7
|
+
<>
|
|
8
8
|
<button onClick={() => params.append('baz', 'qux')}>{'append'}</button>
|
|
9
9
|
<pre>{params.toString()}</pre>
|
|
10
10
|
<pre>{params.size}</pre>
|
|
11
|
-
|
|
11
|
+
</>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
render(URLTest);
|
|
@@ -28,14 +28,14 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
it('handles append with multiple values for same key', () => {
|
|
31
|
-
function URLTest() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
function URLTest() @{
|
|
32
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
33
|
+
let &[allFoo] = track(() => params.getAll('foo'));
|
|
34
|
+
<>
|
|
35
35
|
<button onClick={() => params.append('foo', 'baz')}>{'append foo'}</button>
|
|
36
36
|
<pre>{params.toString()}</pre>
|
|
37
37
|
<pre>{JSON.stringify(allFoo)}</pre>
|
|
38
|
-
|
|
38
|
+
</>
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
render(URLTest);
|
|
@@ -55,14 +55,14 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
55
55
|
});
|
|
56
56
|
|
|
57
57
|
it('handles delete operation with reactivity', () => {
|
|
58
|
-
function URLTest() {
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
function URLTest() @{
|
|
59
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
60
|
+
<>
|
|
61
61
|
<button onClick={() => params.delete('foo')}>{'delete foo'}</button>
|
|
62
62
|
<pre>{params.toString()}</pre>
|
|
63
63
|
<pre>{params.size}</pre>
|
|
64
64
|
<pre>{params.has('foo').toString()}</pre>
|
|
65
|
-
|
|
65
|
+
</>
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
render(URLTest);
|
|
@@ -84,13 +84,13 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
84
84
|
});
|
|
85
85
|
|
|
86
86
|
it('handles delete with specific value', () => {
|
|
87
|
-
function URLTest() {
|
|
88
|
-
|
|
89
|
-
|
|
87
|
+
function URLTest() @{
|
|
88
|
+
const params = RippleURLSearchParams('foo=bar&foo=baz&foo=qux');
|
|
89
|
+
<>
|
|
90
90
|
<button onClick={() => params.delete('foo', 'baz')}>{'delete foo=baz'}</button>
|
|
91
91
|
<pre>{params.toString()}</pre>
|
|
92
92
|
<pre>{params.size}</pre>
|
|
93
|
-
|
|
93
|
+
</>
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
render(URLTest);
|
|
@@ -110,14 +110,14 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
110
110
|
});
|
|
111
111
|
|
|
112
112
|
it('handles delete when key does not exist', () => {
|
|
113
|
-
function URLTest() {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
function URLTest() @{
|
|
114
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
115
|
+
let &[reactiveSize] = track(() => params.size);
|
|
116
|
+
<>
|
|
117
117
|
<button onClick={() => params.delete('nonexistent')}>{'delete nonexistent'}</button>
|
|
118
118
|
<pre>{params.toString()}</pre>
|
|
119
119
|
<pre>{reactiveSize}</pre>
|
|
120
|
-
|
|
120
|
+
</>
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
render(URLTest);
|
|
@@ -137,14 +137,14 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
137
137
|
});
|
|
138
138
|
|
|
139
139
|
it('handles set operation with reactivity', () => {
|
|
140
|
-
function URLTest() {
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
function URLTest() @{
|
|
141
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
142
|
+
<>
|
|
143
143
|
<button onClick={() => params.set('foo', 'updated')}>{'update foo'}</button>
|
|
144
144
|
<button onClick={() => params.set('baz', 'qux')}>{'add baz'}</button>
|
|
145
145
|
<pre>{params.toString()}</pre>
|
|
146
146
|
<pre>{params.size}</pre>
|
|
147
|
-
|
|
147
|
+
</>
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
render(URLTest);
|
|
@@ -172,14 +172,14 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
172
172
|
});
|
|
173
173
|
|
|
174
174
|
it('handles set with multiple existing values', () => {
|
|
175
|
-
function URLTest() {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
175
|
+
function URLTest() @{
|
|
176
|
+
const params = RippleURLSearchParams('foo=bar&foo=baz&foo=qux');
|
|
177
|
+
let &[allFoo] = track(() => params.getAll('foo'));
|
|
178
|
+
<>
|
|
179
179
|
<button onClick={() => params.set('foo', 'single')}>{'set foo'}</button>
|
|
180
180
|
<pre>{params.toString()}</pre>
|
|
181
181
|
<pre>{JSON.stringify(allFoo)}</pre>
|
|
182
|
-
|
|
182
|
+
</>
|
|
183
183
|
}
|
|
184
184
|
|
|
185
185
|
render(URLTest);
|
|
@@ -199,14 +199,14 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
199
199
|
});
|
|
200
200
|
|
|
201
201
|
it('handles set when value is the same', () => {
|
|
202
|
-
function URLTest() {
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
202
|
+
function URLTest() @{
|
|
203
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
204
|
+
let &[reactiveString] = track(() => params.toString());
|
|
205
|
+
<>
|
|
206
206
|
<button onClick={() => params.set('foo', 'bar')}>{'set same value'}</button>
|
|
207
207
|
<pre>{reactiveString}</pre>
|
|
208
208
|
<pre>{params.size}</pre>
|
|
209
|
-
|
|
209
|
+
</>
|
|
210
210
|
}
|
|
211
211
|
|
|
212
212
|
render(URLTest);
|
|
@@ -225,12 +225,12 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
225
225
|
});
|
|
226
226
|
|
|
227
227
|
it('handles sort operation with reactivity', () => {
|
|
228
|
-
function URLTest() {
|
|
229
|
-
|
|
230
|
-
|
|
228
|
+
function URLTest() @{
|
|
229
|
+
const params = RippleURLSearchParams('z=last&a=first&m=middle');
|
|
230
|
+
<>
|
|
231
231
|
<button onClick={() => params.sort()}>{'sort'}</button>
|
|
232
232
|
<pre>{params.toString()}</pre>
|
|
233
|
-
|
|
233
|
+
</>
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
render(URLTest);
|
|
@@ -248,21 +248,19 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
248
248
|
});
|
|
249
249
|
|
|
250
250
|
it('handles clearing all params via delete', () => {
|
|
251
|
-
function URLTest() {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
251
|
+
function URLTest() @{
|
|
252
|
+
const url = RippleURL('https://example.com?foo=bar&baz=qux');
|
|
253
|
+
const params = url.searchParams;
|
|
254
|
+
<>
|
|
255
255
|
<button
|
|
256
256
|
onClick={() => {
|
|
257
257
|
params.delete('foo');
|
|
258
258
|
params.delete('baz');
|
|
259
259
|
}}
|
|
260
|
-
>
|
|
261
|
-
{'clear all'}
|
|
262
|
-
</button>
|
|
260
|
+
>{'clear all'}</button>
|
|
263
261
|
<pre>{url.href}</pre>
|
|
264
262
|
<pre>{params.size}</pre>
|
|
265
|
-
|
|
263
|
+
</>
|
|
266
264
|
}
|
|
267
265
|
|
|
268
266
|
render(URLTest);
|
|
@@ -284,9 +282,9 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
284
282
|
});
|
|
285
283
|
|
|
286
284
|
it('handles multiple operations in sequence', () => {
|
|
287
|
-
function URLTest() {
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
function URLTest() @{
|
|
286
|
+
const params = RippleURLSearchParams();
|
|
287
|
+
<>
|
|
290
288
|
<button
|
|
291
289
|
onClick={() => {
|
|
292
290
|
params.append('a', '1');
|
|
@@ -296,12 +294,10 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
296
294
|
params.append('c', '3');
|
|
297
295
|
params.sort();
|
|
298
296
|
}}
|
|
299
|
-
>
|
|
300
|
-
{'complex operations'}
|
|
301
|
-
</button>
|
|
297
|
+
>{'complex operations'}</button>
|
|
302
298
|
<pre>{params.toString()}</pre>
|
|
303
299
|
<pre>{params.size}</pre>
|
|
304
|
-
|
|
300
|
+
</>
|
|
305
301
|
}
|
|
306
302
|
|
|
307
303
|
render(URLTest);
|
|
@@ -321,16 +317,16 @@ describe('RippleURLSearchParams > mutation', () => {
|
|
|
321
317
|
});
|
|
322
318
|
|
|
323
319
|
it('handles duplicate keys with different values', () => {
|
|
324
|
-
function URLTest() {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
320
|
+
function URLTest() @{
|
|
321
|
+
const params = RippleURLSearchParams();
|
|
322
|
+
let &[tags] = track(() => params.getAll('tag'));
|
|
323
|
+
<>
|
|
328
324
|
<button onClick={() => params.append('tag', 'javascript')}>{'add js'}</button>
|
|
329
325
|
<button onClick={() => params.append('tag', 'typescript')}>{'add ts'}</button>
|
|
330
326
|
<button onClick={() => params.append('tag', 'ripple')}>{'add ripple'}</button>
|
|
331
327
|
<pre>{JSON.stringify(tags)}</pre>
|
|
332
328
|
<pre>{params.size}</pre>
|
|
333
|
-
|
|
329
|
+
</>
|
|
334
330
|
}
|
|
335
331
|
|
|
336
332
|
render(URLTest);
|
|
@@ -2,15 +2,15 @@ import { RippleURL, RippleURLSearchParams, flushSync, track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('RippleURLSearchParams > retrieval', () => {
|
|
4
4
|
it('handles get operation with reactivity', () => {
|
|
5
|
-
function URLTest() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
function URLTest() @{
|
|
6
|
+
const params = RippleURLSearchParams('foo=bar&baz=qux');
|
|
7
|
+
let &[foo] = track(() => params.get('foo'));
|
|
8
|
+
let &[baz] = track(() => params.get('baz'));
|
|
9
|
+
<>
|
|
10
10
|
<button onClick={() => params.set('foo', 'updated')}>{'update foo'}</button>
|
|
11
11
|
<pre>{foo}</pre>
|
|
12
12
|
<pre>{baz}</pre>
|
|
13
|
-
|
|
13
|
+
</>
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
render(URLTest);
|
|
@@ -30,12 +30,10 @@ describe('RippleURLSearchParams > retrieval', () => {
|
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
it('handles get for nonexistent key', () => {
|
|
33
|
-
function URLTest() {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
<pre>{String(nonexistent)}</pre>
|
|
38
|
-
</>;
|
|
33
|
+
function URLTest() @{
|
|
34
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
35
|
+
let &[nonexistent] = track(() => params.get('nonexistent'));
|
|
36
|
+
<pre>{String(nonexistent)}</pre>
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
render(URLTest);
|
|
@@ -44,13 +42,13 @@ describe('RippleURLSearchParams > retrieval', () => {
|
|
|
44
42
|
});
|
|
45
43
|
|
|
46
44
|
it('handles getAll operation with reactivity', () => {
|
|
47
|
-
function URLTest() {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
function URLTest() @{
|
|
46
|
+
const params = RippleURLSearchParams('foo=bar&foo=baz');
|
|
47
|
+
let &[allFoo] = track(() => params.getAll('foo'));
|
|
48
|
+
<>
|
|
51
49
|
<button onClick={() => params.append('foo', 'qux')}>{'append foo'}</button>
|
|
52
50
|
<pre>{JSON.stringify(allFoo)}</pre>
|
|
53
|
-
|
|
51
|
+
</>
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
render(URLTest);
|
|
@@ -68,16 +66,16 @@ describe('RippleURLSearchParams > retrieval', () => {
|
|
|
68
66
|
});
|
|
69
67
|
|
|
70
68
|
it('handles has operation with reactivity', () => {
|
|
71
|
-
function URLTest() {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
69
|
+
function URLTest() @{
|
|
70
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
71
|
+
let &[hasFoo] = track(() => params.has('foo'));
|
|
72
|
+
let &[hasBaz] = track(() => params.has('baz'));
|
|
73
|
+
<>
|
|
76
74
|
<button onClick={() => params.append('baz', 'qux')}>{'add baz'}</button>
|
|
77
75
|
<button onClick={() => params.delete('foo')}>{'delete foo'}</button>
|
|
78
76
|
<pre>{hasFoo.toString()}</pre>
|
|
79
77
|
<pre>{hasBaz.toString()}</pre>
|
|
80
|
-
|
|
78
|
+
</>
|
|
81
79
|
}
|
|
82
80
|
|
|
83
81
|
render(URLTest);
|
|
@@ -105,15 +103,15 @@ describe('RippleURLSearchParams > retrieval', () => {
|
|
|
105
103
|
});
|
|
106
104
|
|
|
107
105
|
it('handles has with specific value', () => {
|
|
108
|
-
function URLTest() {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
106
|
+
function URLTest() @{
|
|
107
|
+
const params = RippleURLSearchParams('foo=bar&foo=baz');
|
|
108
|
+
let &[hasBarValue] = track(() => params.has('foo', 'bar'));
|
|
109
|
+
let &[hasQuxValue] = track(() => params.has('foo', 'qux'));
|
|
110
|
+
<>
|
|
113
111
|
<button onClick={() => params.append('foo', 'qux')}>{'add qux'}</button>
|
|
114
112
|
<pre>{hasBarValue.toString()}</pre>
|
|
115
113
|
<pre>{hasQuxValue.toString()}</pre>
|
|
116
|
-
|
|
114
|
+
</>
|
|
117
115
|
}
|
|
118
116
|
|
|
119
117
|
render(URLTest);
|
|
@@ -133,14 +131,14 @@ describe('RippleURLSearchParams > retrieval', () => {
|
|
|
133
131
|
});
|
|
134
132
|
|
|
135
133
|
it('handles size property with reactivity', () => {
|
|
136
|
-
function URLTest() {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
function URLTest() @{
|
|
135
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
136
|
+
let &[size] = track(() => params.size);
|
|
137
|
+
<>
|
|
140
138
|
<button onClick={() => params.append('baz', 'qux')}>{'add'}</button>
|
|
141
139
|
<button onClick={() => params.delete('foo')}>{'delete'}</button>
|
|
142
140
|
<pre>{size}</pre>
|
|
143
|
-
|
|
141
|
+
</>
|
|
144
142
|
}
|
|
145
143
|
|
|
146
144
|
render(URLTest);
|
|
@@ -2,13 +2,13 @@ import { RippleURL, RippleURLSearchParams, flushSync, track } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('RippleURLSearchParams > serialization', () => {
|
|
4
4
|
it('handles toString method with reactivity', () => {
|
|
5
|
-
function URLTest() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function URLTest() @{
|
|
6
|
+
const params = RippleURLSearchParams('foo=bar');
|
|
7
|
+
let &[string] = track(() => params.toString());
|
|
8
|
+
<>
|
|
9
9
|
<button onClick={() => params.append('baz', 'qux')}>{'add'}</button>
|
|
10
10
|
<pre>{string}</pre>
|
|
11
|
-
|
|
11
|
+
</>
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
render(URLTest);
|
|
@@ -26,13 +26,13 @@ describe('RippleURLSearchParams > serialization', () => {
|
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
it('handles special characters encoding', () => {
|
|
29
|
-
function URLTest() {
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
function URLTest() @{
|
|
30
|
+
const params = RippleURLSearchParams();
|
|
31
|
+
<>
|
|
32
32
|
<button onClick={() => params.set('key', 'value with spaces')}>{'add spaces'}</button>
|
|
33
33
|
<button onClick={() => params.set('special', '!@#$%^&*()')}>{'add special'}</button>
|
|
34
34
|
<pre>{params.toString()}</pre>
|
|
35
|
-
|
|
35
|
+
</>
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
render(URLTest);
|
|
@@ -2,14 +2,14 @@ import { RippleURL, flushSync } from 'ripple';
|
|
|
2
2
|
|
|
3
3
|
describe('RippleURLSearchParams > RippleURL integration', () => {
|
|
4
4
|
it('integrates with RippleURL', () => {
|
|
5
|
-
function URLTest() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
function URLTest() @{
|
|
6
|
+
const url = RippleURL('https://example.com?foo=bar');
|
|
7
|
+
const params = url.searchParams;
|
|
8
|
+
<>
|
|
9
9
|
<button onClick={() => params.append('baz', 'qux')}>{'add param'}</button>
|
|
10
10
|
<pre>{url.href}</pre>
|
|
11
11
|
<pre>{params.toString()}</pre>
|
|
12
|
-
|
|
12
|
+
</>
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
render(URLTest);
|
|
@@ -31,14 +31,14 @@ describe('RippleURLSearchParams > RippleURL integration', () => {
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
it('handles empty search string in URL', () => {
|
|
34
|
-
function URLTest() {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
34
|
+
function URLTest() @{
|
|
35
|
+
const url = RippleURL('https://example.com');
|
|
36
|
+
const params = url.searchParams;
|
|
37
|
+
<>
|
|
38
38
|
<button onClick={() => params.append('foo', 'bar')}>{'add first param'}</button>
|
|
39
39
|
<pre>{url.href}</pre>
|
|
40
40
|
<pre>{params.size}</pre>
|
|
41
|
-
|
|
41
|
+
</>
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
render(URLTest);
|