File tree 6 files changed +48
-1
lines changed
src/compiler/compile/render_ssr
runtime/samples/reactive-assignment-in-complex-declaration-with-store-3
6 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 3
3
## Unreleased
4
4
5
5
* Throw a parser error for ` class: ` directives with an empty class name ([ #5858 ] ( https://github.com/sveltejs/svelte/issues/5858 ) )
6
+ * Fix extraneous store subscription in SSR mode ([ #5883 ] ( https://github.com/sveltejs/svelte/issues/5883 ) )
6
7
* Fix type inference for derived stores ([ #5935 ] ( https://github.com/sveltejs/svelte/pull/5935 ) )
7
8
* Make parameters of built-in animations and transitions optional ([ #5936 ] ( https://github.com/sveltejs/svelte/pull/5936 ) )
8
9
* Make ` SvelteComponentDev ` typings more forgiving ([ #5937 ] ( https://github.com/sveltejs/svelte/pull/5937 ) )
Original file line number Diff line number Diff line change @@ -51,7 +51,6 @@ export default function ssr(
51
51
return b `
52
52
${ component . compile_options . dev && b `@validate_store(${ store_name } , '${ store_name } ');` }
53
53
${ `$$unsubscribe_${ store_name } ` } = @subscribe(${ store_name } , #value => ${ name } = #value)
54
- ${ store_name } .subscribe($$value => ${ name } = $$value);
55
54
` ;
56
55
} ) ;
57
56
const reactive_store_unsubscriptions = reactive_stores . map (
Original file line number Diff line number Diff line change
1
+ import { store } from './store.js' ;
2
+
3
+ export default {
4
+ html : '<h1>0</h1>' ,
5
+ before_test ( ) {
6
+ store . reset ( ) ;
7
+ } ,
8
+ async test ( { assert, target, component } ) {
9
+ store . set ( 42 ) ;
10
+
11
+ await Promise . resolve ( ) ;
12
+
13
+ assert . htmlEqual ( target . innerHTML , '<h1>42</h1>' ) ;
14
+
15
+ assert . equal ( store . numberOfTimesSubscribeCalled ( ) , 1 ) ;
16
+ } ,
17
+ test_ssr ( { assert } ) {
18
+ assert . equal ( store . numberOfTimesSubscribeCalled ( ) , 1 ) ;
19
+ }
20
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ import { store } from ' ./store' ;
3
+ </script >
4
+
5
+ <h1 >{$store }</h1 >
Original file line number Diff line number Diff line change
1
+ import { writable } from '../../../../store' ;
2
+ const _store = writable ( 0 ) ;
3
+ let count = 0 ;
4
+
5
+ export const store = {
6
+ ..._store ,
7
+ subscribe ( fn ) {
8
+ count ++ ;
9
+ return _store . subscribe ( fn ) ;
10
+ } ,
11
+ reset ( ) {
12
+ count = 0 ;
13
+ _store . set ( 0 ) ;
14
+ } ,
15
+ numberOfTimesSubscribeCalled ( ) {
16
+ return count ;
17
+ }
18
+ } ;
Original file line number Diff line number Diff line change @@ -201,6 +201,10 @@ describe('ssr', () => {
201
201
assert . htmlEqual ( html , config . html ) ;
202
202
}
203
203
204
+ if ( config . test_ssr ) {
205
+ config . test_ssr ( { assert } ) ;
206
+ }
207
+
204
208
if ( config . after_test ) config . after_test ( ) ;
205
209
206
210
if ( config . show ) {
You can’t perform that action at this time.
0 commit comments