ripple 0.3.72 → 0.3.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +116 -0
- package/package.json +3 -3
- package/src/jsx-runtime.d.ts +4 -10
- package/src/runtime/dynamic-client.js +33 -0
- package/src/runtime/dynamic-server.js +80 -0
- package/src/runtime/index-client.js +5 -13
- package/src/runtime/index-server.js +2 -0
- package/src/runtime/internal/client/blocks.js +6 -27
- package/src/runtime/internal/client/composite.js +11 -6
- package/src/runtime/internal/client/for.js +80 -5
- package/src/runtime/internal/client/index.js +0 -2
- package/src/runtime/internal/client/render.js +5 -2
- package/src/runtime/internal/client/types.d.ts +0 -10
- package/src/runtime/internal/server/index.js +8 -1
- package/tests/client/__snapshots__/computed-properties.test.tsrx.snap +8 -0
- package/tests/client/__snapshots__/for.test.tsrx.snap +22 -0
- package/tests/client/__snapshots__/html.test.tsrx.snap +4 -0
- package/tests/client/array/array.copy-within.test.tsrx +19 -19
- package/tests/client/array/array.derived.test.tsrx +97 -109
- package/tests/client/array/array.iteration.test.tsrx +28 -28
- package/tests/client/array/array.mutations.test.tsrx +68 -68
- package/tests/client/array/array.static.test.tsrx +82 -92
- package/tests/client/array/array.to-methods.test.tsrx +15 -15
- package/tests/client/async-suspend.test.tsrx +180 -179
- package/tests/client/basic/__snapshots__/basic.attributes.test.tsrx.snap +2 -0
- package/tests/client/basic/__snapshots__/basic.rendering.test.tsrx.snap +4 -0
- package/tests/client/basic/basic.attributes.test.tsrx +273 -317
- package/tests/client/basic/basic.collections.test.tsrx +55 -61
- package/tests/client/basic/basic.components.test.tsrx +198 -220
- package/tests/client/basic/basic.errors.test.tsrx +70 -76
- package/tests/client/basic/basic.events.test.tsrx +80 -85
- package/tests/client/basic/basic.get-set.test.tsrx +54 -64
- package/tests/client/basic/basic.hmr.test.tsrx +15 -19
- package/tests/client/basic/basic.reactivity.test.tsrx +121 -135
- package/tests/client/basic/basic.rendering.test.tsrx +273 -178
- package/tests/client/basic/basic.styling.test.tsrx +16 -14
- package/tests/client/basic/basic.utilities.test.tsrx +8 -10
- package/tests/client/boundaries.test.tsrx +18 -18
- package/tests/client/compiler/compiler.assignments.test.tsrx +77 -76
- package/tests/client/compiler/compiler.attributes.test.tsrx +18 -14
- package/tests/client/compiler/compiler.basic.test.tsrx +357 -288
- package/tests/client/compiler/compiler.regex.test.tsrx +40 -44
- package/tests/client/compiler/compiler.tracked-access.test.tsrx +57 -38
- package/tests/client/compiler/compiler.try-in-function.test.tsrx +16 -16
- package/tests/client/compiler/compiler.typescript.test.tsrx +4 -3
- package/tests/client/composite/composite.dynamic-components.test.tsrx +62 -47
- package/tests/client/composite/composite.generics.test.tsrx +165 -167
- package/tests/client/composite/composite.props.test.tsrx +66 -74
- package/tests/client/composite/composite.reactivity.test.tsrx +132 -166
- package/tests/client/composite/composite.render.test.tsrx +92 -101
- package/tests/client/computed-properties.test.tsrx +14 -18
- package/tests/client/context.test.tsrx +14 -18
- package/tests/client/css/global-additional-cases.test.tsrx +493 -439
- package/tests/client/css/global-advanced-selectors.test.tsrx +169 -153
- package/tests/client/css/global-at-rules.test.tsrx +71 -66
- package/tests/client/css/global-basic.test.tsrx +105 -98
- package/tests/client/css/global-classes-ids.test.tsrx +128 -114
- package/tests/client/css/global-combinators.test.tsrx +83 -78
- package/tests/client/css/global-complex-nesting.test.tsrx +134 -120
- package/tests/client/css/global-edge-cases.test.tsrx +138 -120
- package/tests/client/css/global-keyframes.test.tsrx +108 -96
- package/tests/client/css/global-nested.test.tsrx +88 -78
- package/tests/client/css/global-pseudo.test.tsrx +104 -98
- package/tests/client/css/global-scoping.test.tsrx +145 -125
- package/tests/client/css/style-identifier.test.tsrx +65 -72
- package/tests/client/date.test.tsrx +83 -83
- package/tests/client/dynamic-elements.test.tsrx +318 -299
- package/tests/client/events.test.tsrx +252 -266
- package/tests/client/for.test.tsrx +120 -127
- package/tests/client/head.test.tsrx +74 -48
- package/tests/client/html.test.tsrx +37 -49
- package/tests/client/input-value.test.tsrx +1125 -1354
- package/tests/client/lazy-array.test.tsrx +10 -16
- package/tests/client/lazy-destructuring.test.tsrx +169 -221
- package/tests/client/map.test.tsrx +39 -41
- package/tests/client/media-query.test.tsrx +15 -19
- package/tests/client/object.test.tsrx +46 -56
- package/tests/client/portal.test.tsrx +31 -37
- package/tests/client/ref.test.tsrx +173 -193
- package/tests/client/return.test.tsrx +62 -37
- package/tests/client/set.test.tsrx +33 -33
- package/tests/client/svg.test.tsrx +197 -216
- package/tests/client/switch.test.tsrx +201 -191
- package/tests/client/track-async-hydration.test.tsrx +14 -18
- package/tests/client/tracked-index-access.test.tsrx +18 -28
- package/tests/client/try.test.tsrx +494 -619
- package/tests/client/tsx.test.tsrx +286 -292
- package/tests/client/typescript-generics.test.tsrx +121 -129
- package/tests/client/url/url.derived.test.tsrx +21 -25
- package/tests/client/url/url.parsing.test.tsrx +35 -35
- package/tests/client/url/url.partial-removal.test.tsrx +32 -32
- package/tests/client/url/url.reactivity.test.tsrx +68 -72
- package/tests/client/url/url.serialization.test.tsrx +8 -8
- package/tests/client/url-search-params/url-search-params.derived.test.tsrx +21 -27
- package/tests/client/url-search-params/url-search-params.initialization.test.tsrx +16 -16
- package/tests/client/url-search-params/url-search-params.iteration.test.tsrx +37 -37
- package/tests/client/url-search-params/url-search-params.mutation.test.tsrx +56 -60
- package/tests/client/url-search-params/url-search-params.retrieval.test.tsrx +32 -34
- package/tests/client/url-search-params/url-search-params.serialization.test.tsrx +9 -9
- package/tests/client/url-search-params/url-search-params.tracked-url.test.tsrx +10 -10
- package/tests/hydration/compiled/client/basic.js +390 -319
- package/tests/hydration/compiled/client/composite.js +52 -44
- package/tests/hydration/compiled/client/for.js +734 -604
- package/tests/hydration/compiled/client/head.js +183 -103
- package/tests/hydration/compiled/client/html.js +93 -86
- package/tests/hydration/compiled/client/if-children.js +95 -71
- package/tests/hydration/compiled/client/if.js +113 -89
- package/tests/hydration/compiled/client/mixed-control-flow.js +225 -209
- package/tests/hydration/compiled/client/nested-control-flow.js +94 -98
- package/tests/hydration/compiled/client/reactivity.js +26 -24
- package/tests/hydration/compiled/client/return.js +8 -42
- package/tests/hydration/compiled/client/switch.js +208 -173
- package/tests/hydration/compiled/client/track-async-serialization.js +176 -128
- package/tests/hydration/compiled/client/try.js +29 -21
- package/tests/hydration/compiled/server/basic.js +210 -221
- package/tests/hydration/compiled/server/composite.js +13 -14
- package/tests/hydration/compiled/server/for.js +427 -444
- package/tests/hydration/compiled/server/head.js +199 -189
- package/tests/hydration/compiled/server/html.js +33 -41
- package/tests/hydration/compiled/server/if-children.js +114 -117
- package/tests/hydration/compiled/server/if.js +77 -83
- package/tests/hydration/compiled/server/mixed-control-flow.js +145 -150
- package/tests/hydration/compiled/server/nested-control-flow.js +10 -0
- package/tests/hydration/compiled/server/reactivity.js +24 -22
- package/tests/hydration/compiled/server/return.js +6 -18
- package/tests/hydration/compiled/server/switch.js +179 -176
- package/tests/hydration/compiled/server/track-async-serialization.js +88 -70
- package/tests/hydration/compiled/server/try.js +31 -35
- package/tests/hydration/components/basic.tsrx +216 -258
- package/tests/hydration/components/composite.tsrx +32 -42
- package/tests/hydration/components/events.tsrx +81 -101
- package/tests/hydration/components/for.tsrx +270 -336
- package/tests/hydration/components/head.tsrx +43 -39
- package/tests/hydration/components/hmr.tsrx +16 -22
- package/tests/hydration/components/html-in-template.tsrx +15 -21
- package/tests/hydration/components/html.tsrx +442 -526
- package/tests/hydration/components/if-children.tsrx +107 -125
- package/tests/hydration/components/if.tsrx +68 -90
- package/tests/hydration/components/mixed-control-flow.tsrx +65 -72
- package/tests/hydration/components/nested-control-flow.tsrx +202 -216
- package/tests/hydration/components/portal.tsrx +33 -41
- package/tests/hydration/components/reactivity.tsrx +26 -34
- package/tests/hydration/components/return.tsrx +4 -6
- package/tests/hydration/components/switch.tsrx +73 -78
- package/tests/hydration/components/track-async-serialization.tsrx +83 -93
- package/tests/hydration/components/try.tsrx +37 -51
- package/tests/hydration/switch.test.js +8 -8
- package/tests/server/await.test.tsrx +3 -3
- package/tests/server/basic.attributes.test.tsrx +117 -162
- package/tests/server/basic.components.test.tsrx +164 -194
- package/tests/server/basic.test.tsrx +299 -199
- package/tests/server/compiler.test.tsrx +142 -72
- package/tests/server/composite.props.test.tsrx +54 -58
- package/tests/server/composite.test.tsrx +165 -167
- package/tests/server/context.test.tsrx +13 -17
- package/tests/server/dynamic-elements.test.tsrx +147 -148
- package/tests/server/for.test.tsrx +115 -84
- package/tests/server/head.test.tsrx +54 -31
- package/tests/server/html-nesting-validation.test.tsrx +16 -8
- package/tests/server/if.test.tsrx +49 -59
- package/tests/server/lazy-destructuring.test.tsrx +288 -366
- package/tests/server/return.test.tsrx +58 -36
- package/tests/server/streaming-ssr.test.tsrx +4 -4
- package/tests/server/style-identifier.test.tsrx +61 -69
- package/tests/server/switch.test.tsrx +89 -97
- package/tests/server/track-async-serialization.test.tsrx +85 -103
- package/tests/server/try.test.tsrx +275 -360
- package/tests/utils/ref-types.test.js +72 -0
- package/tests/utils/vite-plugin-config.test.js +41 -74
- package/types/index.d.ts +29 -4
- package/src/runtime/internal/client/compat.js +0 -40
- package/tests/utils/compiler-compat-config.test.js +0 -38
|
@@ -2,369 +2,327 @@
|
|
|
2
2
|
import { track } from 'ripple';
|
|
3
3
|
import type { Children } from 'ripple';
|
|
4
4
|
|
|
5
|
-
export function StaticText() {
|
|
6
|
-
|
|
5
|
+
export function StaticText() @{
|
|
6
|
+
<div>{'Hello World'}</div>
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function MultipleElements() {
|
|
10
|
-
|
|
9
|
+
export function MultipleElements() @{
|
|
10
|
+
<>
|
|
11
11
|
<h1>{'Title'}</h1>
|
|
12
12
|
<p>{'Paragraph text'}</p>
|
|
13
13
|
<span>{'Span text'}</span>
|
|
14
|
-
|
|
14
|
+
</>
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function NestedElements() {
|
|
18
|
-
|
|
19
|
-
<div class="
|
|
20
|
-
<
|
|
21
|
-
<span>{'Nested content'}</span>
|
|
22
|
-
</div>
|
|
17
|
+
export function NestedElements() @{
|
|
18
|
+
<div class="outer">
|
|
19
|
+
<div class="inner">
|
|
20
|
+
<span>{'Nested content'}</span>
|
|
23
21
|
</div>
|
|
24
|
-
|
|
22
|
+
</div>
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
export function WithAttributes() {
|
|
28
|
-
|
|
25
|
+
export function WithAttributes() @{
|
|
26
|
+
<>
|
|
29
27
|
<input type="text" placeholder="Enter text" disabled />
|
|
30
28
|
<a href="/link" target="_blank">{'Link'}</a>
|
|
31
|
-
|
|
29
|
+
</>
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
export function ChildComponent() {
|
|
35
|
-
|
|
32
|
+
export function ChildComponent() @{
|
|
33
|
+
<span class="child">{'Child content'}</span>
|
|
36
34
|
}
|
|
37
35
|
|
|
38
|
-
export function ParentWithChild() {
|
|
39
|
-
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
</div>
|
|
43
|
-
</>;
|
|
36
|
+
export function ParentWithChild() @{
|
|
37
|
+
<div class="parent">
|
|
38
|
+
<ChildComponent />
|
|
39
|
+
</div>
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
export function FirstSibling() {
|
|
47
|
-
|
|
42
|
+
export function FirstSibling() @{
|
|
43
|
+
<div class="first">{'First'}</div>
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
export function SecondSibling() {
|
|
51
|
-
|
|
46
|
+
export function SecondSibling() @{
|
|
47
|
+
<div class="second">{'Second'}</div>
|
|
52
48
|
}
|
|
53
49
|
|
|
54
|
-
export function SiblingComponents() {
|
|
55
|
-
|
|
50
|
+
export function SiblingComponents() @{
|
|
51
|
+
<>
|
|
56
52
|
<FirstSibling />
|
|
57
53
|
<SecondSibling />
|
|
58
|
-
|
|
54
|
+
</>
|
|
59
55
|
}
|
|
60
56
|
|
|
61
|
-
export function Greeting(props: { name: string }) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
</div>
|
|
67
|
-
</>;
|
|
57
|
+
export function Greeting(props: { name: string }) @{
|
|
58
|
+
<div>
|
|
59
|
+
{'Hello '}
|
|
60
|
+
{props.name}
|
|
61
|
+
</div>
|
|
68
62
|
}
|
|
69
63
|
|
|
70
|
-
export function WithGreeting() {
|
|
71
|
-
|
|
64
|
+
export function WithGreeting() @{
|
|
65
|
+
<Greeting name="World" />
|
|
72
66
|
}
|
|
73
67
|
|
|
74
|
-
export function ExpressionContent() {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
68
|
+
export function ExpressionContent() @{
|
|
69
|
+
const value = 42;
|
|
70
|
+
const label = 'computed';
|
|
71
|
+
<>
|
|
78
72
|
<div>{value}</div>
|
|
79
73
|
<span>{label.toUpperCase()}</span>
|
|
80
|
-
|
|
74
|
+
</>
|
|
81
75
|
}
|
|
82
76
|
|
|
83
|
-
function NestedHelperItem({ item }: { item: number }) {
|
|
84
|
-
|
|
77
|
+
function NestedHelperItem({ item }: { item: number }) @{
|
|
78
|
+
<div class="helper-item">{item}</div>
|
|
85
79
|
}
|
|
86
80
|
|
|
87
|
-
function NestedTsxTsrxFragment({ label }: { label: string }) {
|
|
88
|
-
|
|
81
|
+
function NestedTsxTsrxFragment({ label }: { label: string }) @{
|
|
82
|
+
<>
|
|
89
83
|
<span class="label">{label}</span>
|
|
90
|
-
for (const item of [1, 2, 3, 4]) {
|
|
84
|
+
@for (const item of [1, 2, 3, 4]) {
|
|
91
85
|
<NestedHelperItem {item} />
|
|
92
86
|
}
|
|
93
|
-
|
|
87
|
+
</>
|
|
94
88
|
}
|
|
95
89
|
|
|
96
|
-
export function NestedTsxTsrxExpressionValues() {
|
|
97
|
-
|
|
98
|
-
for (const item of [1, 2, 3]) {
|
|
90
|
+
export function NestedTsxTsrxExpressionValues() @{
|
|
91
|
+
<div class="nested-expression-values">
|
|
92
|
+
@for (const item of [1, 2, 3]) {
|
|
99
93
|
<div class="app-item">{item}</div>
|
|
100
94
|
}
|
|
101
95
|
<NestedTsxTsrxFragment label="from helper" />
|
|
102
|
-
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export function MixedTsrxCollectionText() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
{[
|
|
178
|
-
'count: ',
|
|
179
|
-
2,
|
|
180
|
-
' / ',
|
|
181
|
-
false,
|
|
182
|
-
<span class="primitive-tail">{' ok'}</span>,
|
|
183
|
-
]}
|
|
184
|
-
</>;
|
|
185
|
-
<div class="mixed-collection-primitive">{content}</div>
|
|
186
|
-
</>;
|
|
96
|
+
</div>
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function MixedTsrxCollectionText() @{
|
|
100
|
+
const content = <>
|
|
101
|
+
{[
|
|
102
|
+
'alpha ',
|
|
103
|
+
<strong class="middle">{'beta'}</strong>,
|
|
104
|
+
' gamma ',
|
|
105
|
+
[
|
|
106
|
+
'delta ',
|
|
107
|
+
<em class="tail">{'epsilon'}</em>,
|
|
108
|
+
' zeta',
|
|
109
|
+
],
|
|
110
|
+
]}
|
|
111
|
+
</>;
|
|
112
|
+
<div class="mixed-collection">{content}</div>
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function MixedTsrxCollectionSplitServerText() @{
|
|
116
|
+
const content = <>
|
|
117
|
+
{[
|
|
118
|
+
'alpha ',
|
|
119
|
+
<strong class="middle">{'beta'}</strong>,
|
|
120
|
+
' gamma ',
|
|
121
|
+
[
|
|
122
|
+
'delta ',
|
|
123
|
+
<em class="tail">{'epsilon'}</em>,
|
|
124
|
+
' zeta',
|
|
125
|
+
],
|
|
126
|
+
]}
|
|
127
|
+
</>;
|
|
128
|
+
<div class="mixed-collection-split">{content}</div>
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function MixedTsrxCollectionSplitClientText() @{
|
|
132
|
+
const content = <>
|
|
133
|
+
{[
|
|
134
|
+
'alpha ',
|
|
135
|
+
<strong class="middle">{'beta'}</strong>,
|
|
136
|
+
' gamma ',
|
|
137
|
+
[
|
|
138
|
+
'changed ',
|
|
139
|
+
<em class="tail">{'epsilon'}</em>,
|
|
140
|
+
' zeta',
|
|
141
|
+
],
|
|
142
|
+
]}
|
|
143
|
+
</>;
|
|
144
|
+
<div class="mixed-collection-split">{content}</div>
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function MixedTsrxCollectionPrimitiveServerText() @{
|
|
148
|
+
const content = <>
|
|
149
|
+
{[
|
|
150
|
+
'count: ',
|
|
151
|
+
1,
|
|
152
|
+
' / ',
|
|
153
|
+
true,
|
|
154
|
+
<span class="primitive-tail">{' ok'}</span>,
|
|
155
|
+
]}
|
|
156
|
+
</>;
|
|
157
|
+
<div class="mixed-collection-primitive">{content}</div>
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function MixedTsrxCollectionPrimitiveClientText() @{
|
|
161
|
+
const content = <>
|
|
162
|
+
{[
|
|
163
|
+
'count: ',
|
|
164
|
+
2,
|
|
165
|
+
' / ',
|
|
166
|
+
false,
|
|
167
|
+
<span class="primitive-tail">{' ok'}</span>,
|
|
168
|
+
]}
|
|
169
|
+
</>;
|
|
170
|
+
<div class="mixed-collection-primitive">{content}</div>
|
|
187
171
|
}
|
|
188
172
|
|
|
189
173
|
function createPrimitiveItems() {
|
|
190
174
|
return ['start:', ['one', 2], true, null, false, ':end'];
|
|
191
175
|
}
|
|
192
176
|
|
|
193
|
-
export function DynamicArrayFromCall() {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
<div class="dynamic-array-call">{items}</div>
|
|
197
|
-
</>;
|
|
177
|
+
export function DynamicArrayFromCall() @{
|
|
178
|
+
const items = createPrimitiveItems();
|
|
179
|
+
<div class="dynamic-array-call">{items}</div>
|
|
198
180
|
}
|
|
199
181
|
|
|
200
|
-
export function DynamicArrayFromTrack() {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
<div class="dynamic-array-track">{items}</div>
|
|
204
|
-
</>;
|
|
182
|
+
export function DynamicArrayFromTrack() @{
|
|
183
|
+
let &[items] = track(['start:', ['one', 2], true, null, false, ':end']);
|
|
184
|
+
<div class="dynamic-array-track">{items}</div>
|
|
205
185
|
}
|
|
206
186
|
|
|
207
|
-
export function DynamicArrayFromConditional() {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
<div class="dynamic-array-conditional">{items}</div>
|
|
212
|
-
</>;
|
|
187
|
+
export function DynamicArrayFromConditional() @{
|
|
188
|
+
const condition = true;
|
|
189
|
+
const items = condition ? ['start:', ['one', 2], true, null, false, ':end'] : ['fallback'];
|
|
190
|
+
<div class="dynamic-array-conditional">{items}</div>
|
|
213
191
|
}
|
|
214
192
|
|
|
215
|
-
export function DynamicArrayFromLogical() {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
<div class="dynamic-array-logical">{items}</div>
|
|
220
|
-
</>;
|
|
193
|
+
export function DynamicArrayFromLogical() @{
|
|
194
|
+
const condition = true;
|
|
195
|
+
const items = condition && ['start:', ['one', 2], true, null, false, ':end'];
|
|
196
|
+
<div class="dynamic-array-logical">{items}</div>
|
|
221
197
|
}
|
|
222
198
|
|
|
223
|
-
export function NestedTsrxInsideTopLevelTsxExpression() {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
<
|
|
227
|
-
|
|
228
|
-
</section>
|
|
229
|
-
</>;
|
|
230
|
-
{content}
|
|
199
|
+
export function NestedTsrxInsideTopLevelTsxExpression() @{
|
|
200
|
+
const content = <>
|
|
201
|
+
<section class="outer">
|
|
202
|
+
<div class="inner">{'from tsrx'}</div>
|
|
203
|
+
</section>
|
|
231
204
|
</>;
|
|
205
|
+
<>
|
|
206
|
+
{content}
|
|
207
|
+
</>
|
|
232
208
|
}
|
|
233
209
|
|
|
234
|
-
export function NestedTsrxElementsInsideTopLevelTsxValue() {
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
<
|
|
238
|
-
{
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
</section>
|
|
242
|
-
</>}
|
|
243
|
-
</div>
|
|
244
|
-
</>;
|
|
245
|
-
{content}
|
|
210
|
+
export function NestedTsrxElementsInsideTopLevelTsxValue() @{
|
|
211
|
+
const content = <>
|
|
212
|
+
<div class="wrapper">
|
|
213
|
+
<section class="native">
|
|
214
|
+
<span class="nested-tsrx">{'inside nested tsrx'}</span>
|
|
215
|
+
</section>
|
|
216
|
+
</div>
|
|
246
217
|
</>;
|
|
218
|
+
<>
|
|
219
|
+
{content}
|
|
220
|
+
</>
|
|
247
221
|
}
|
|
248
222
|
|
|
249
|
-
export function TsxDeclaredBeforeTopLevelTsx() {
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
223
|
+
export function TsxDeclaredBeforeTopLevelTsx() @{
|
|
224
|
+
const nested = <span class="nested-tsx">inside nested tsx</span>;
|
|
225
|
+
const content = <><div class="native">{nested}</div></>;
|
|
226
|
+
<>
|
|
253
227
|
{content}
|
|
254
|
-
|
|
228
|
+
</>
|
|
255
229
|
}
|
|
256
230
|
|
|
257
|
-
function TextProp(&{ children }: { children: string }) {
|
|
258
|
-
|
|
231
|
+
function TextProp(&{ children }: { children: string }) @{
|
|
232
|
+
<div class="text-prop">{children}</div>
|
|
259
233
|
}
|
|
260
234
|
|
|
261
|
-
export function TextPropWithToggle() {
|
|
262
|
-
|
|
263
|
-
|
|
235
|
+
export function TextPropWithToggle() @{
|
|
236
|
+
let &[show] = track(false);
|
|
237
|
+
<>
|
|
264
238
|
<TextProp children={show ? 'hello' : ''} />
|
|
265
239
|
<button class="show-text" onClick={() => (show = true)}>{'Show'}</button>
|
|
266
|
-
|
|
240
|
+
</>
|
|
267
241
|
}
|
|
268
242
|
|
|
269
243
|
// Test for static content in child component followed by sibling content
|
|
270
|
-
function StaticHeader() {
|
|
271
|
-
|
|
244
|
+
function StaticHeader() @{
|
|
245
|
+
<>
|
|
272
246
|
<h1 class="sr-only">{'heading'}</h1>
|
|
273
247
|
<p class="subtitle">{'first paragraph'}</p>
|
|
274
248
|
<p class="subtitle">{'second paragraph'}</p>
|
|
275
|
-
|
|
249
|
+
</>
|
|
276
250
|
}
|
|
277
251
|
|
|
278
|
-
export function StaticChildWithSiblings() {
|
|
279
|
-
|
|
280
|
-
|
|
252
|
+
export function StaticChildWithSiblings() @{
|
|
253
|
+
const foo = 'bar';
|
|
254
|
+
<>
|
|
281
255
|
<StaticHeader />
|
|
282
256
|
<span class="sibling1">{foo}</span>
|
|
283
257
|
<span class="sibling2">{foo}</span>
|
|
284
|
-
|
|
258
|
+
</>
|
|
285
259
|
}
|
|
286
260
|
|
|
287
261
|
// Website-like components for testing complex hydration scenarios
|
|
288
262
|
|
|
289
|
-
function Header() {
|
|
290
|
-
|
|
263
|
+
function Header() @{
|
|
264
|
+
<>
|
|
291
265
|
<h1 class="sr-only">{'Ripple'}</h1>
|
|
292
266
|
<img src="/images/logo.png" alt="Logo" class="logo" />
|
|
293
267
|
<p class="subtitle">{'the elegant TypeScript UI framework'}</p>
|
|
294
|
-
|
|
268
|
+
</>
|
|
295
269
|
}
|
|
296
270
|
|
|
297
|
-
function Actions({ playgroundVisible = false }: { playgroundVisible: boolean }) {
|
|
298
|
-
|
|
299
|
-
<
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
<a href="/playground" class="playground-link">{'Playground'}</a>
|
|
304
|
-
}
|
|
305
|
-
</div>
|
|
306
|
-
</>;
|
|
271
|
+
function Actions({ playgroundVisible = false }: { playgroundVisible: boolean }) @{
|
|
272
|
+
<div class="social-links">
|
|
273
|
+
<a href="https://github.com" class="github-link">{'GitHub'}</a>
|
|
274
|
+
<a href="https://discord.com" class="discord-link">{'Discord'}</a>
|
|
275
|
+
{playgroundVisible ? <a href="/playground" class="playground-link">{'Playground'}</a> : null}
|
|
276
|
+
</div>
|
|
307
277
|
}
|
|
308
278
|
|
|
309
|
-
function Layout({ children }: { children: Children }) {
|
|
310
|
-
|
|
311
|
-
<
|
|
312
|
-
|
|
313
|
-
</main>
|
|
314
|
-
</>;
|
|
279
|
+
function Layout({ children }: { children: Children }) @{
|
|
280
|
+
<main>
|
|
281
|
+
<div class="container">{children}</div>
|
|
282
|
+
</main>
|
|
315
283
|
}
|
|
316
284
|
|
|
317
|
-
function Content() {
|
|
318
|
-
|
|
319
|
-
<
|
|
320
|
-
|
|
321
|
-
</div>
|
|
322
|
-
</>;
|
|
285
|
+
function Content() @{
|
|
286
|
+
<div class="content">
|
|
287
|
+
<p>{'Some content here'}</p>
|
|
288
|
+
</div>
|
|
323
289
|
}
|
|
324
290
|
|
|
325
|
-
export function WebsiteIndex() {
|
|
326
|
-
|
|
327
|
-
<
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
</Layout>
|
|
333
|
-
</>;
|
|
291
|
+
export function WebsiteIndex() @{
|
|
292
|
+
<Layout>
|
|
293
|
+
<Header />
|
|
294
|
+
<Actions playgroundVisible={true} />
|
|
295
|
+
<Content />
|
|
296
|
+
<Actions playgroundVisible={false} />
|
|
297
|
+
</Layout>
|
|
334
298
|
}
|
|
335
299
|
|
|
336
300
|
// Test case for component as last element with no following siblings.
|
|
337
301
|
// This exercises hydrate_advance() in append() - at the end of content,
|
|
338
302
|
// there's no next sibling and that should be handled gracefully.
|
|
339
|
-
function LastChild() {
|
|
340
|
-
|
|
303
|
+
function LastChild() @{
|
|
304
|
+
<footer class="last-child">{'I am the last child'}</footer>
|
|
341
305
|
}
|
|
342
306
|
|
|
343
|
-
export function ComponentAsLastSibling() {
|
|
344
|
-
|
|
345
|
-
<
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
</div>
|
|
350
|
-
</>;
|
|
307
|
+
export function ComponentAsLastSibling() @{
|
|
308
|
+
<div class="wrapper">
|
|
309
|
+
<h1>{'Header'}</h1>
|
|
310
|
+
<p>{'Some content'}</p>
|
|
311
|
+
<LastChild />
|
|
312
|
+
</div>
|
|
351
313
|
}
|
|
352
314
|
|
|
353
315
|
// Nested version - component is last child inside another component
|
|
354
|
-
function InnerContent() {
|
|
355
|
-
|
|
356
|
-
<
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
<h2>{'Section title'}</h2>
|
|
367
|
-
<InnerContent />
|
|
368
|
-
</section>
|
|
369
|
-
</>;
|
|
316
|
+
function InnerContent() @{
|
|
317
|
+
<div class="inner">
|
|
318
|
+
<span>{'Inner text'}</span>
|
|
319
|
+
<LastChild />
|
|
320
|
+
</div>
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
export function NestedComponentAsLastSibling() @{
|
|
324
|
+
<section class="outer">
|
|
325
|
+
<h2>{'Section title'}</h2>
|
|
326
|
+
<InnerContent />
|
|
327
|
+
</section>
|
|
370
328
|
}
|