File tree Expand file tree Collapse file tree 6 files changed +48
-1
lines changed
src/compiler/compile/render_ssr
runtime/samples/reactive-assignment-in-complex-declaration-with-store-3 Expand file tree Collapse file tree 6 files changed +48
-1
lines changed Original file line number Diff line number Diff line change 33## Unreleased
44
55* 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 ) )
67* Fix type inference for derived stores ([ #5935 ] ( https://github.com/sveltejs/svelte/pull/5935 ) )
78* Make parameters of built-in animations and transitions optional ([ #5936 ] ( https://github.com/sveltejs/svelte/pull/5936 ) )
89* 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(
5151 return b `
5252 ${ component . compile_options . dev && b `@validate_store(${ store_name } , '${ store_name } ');` }
5353 ${ `$$unsubscribe_${ store_name } ` } = @subscribe(${ store_name } , #value => ${ name } = #value)
54- ${ store_name } .subscribe($$value => ${ name } = $$value);
5554 ` ;
5655 } ) ;
5756 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', () => {
201201 assert . htmlEqual ( html , config . html ) ;
202202 }
203203
204+ if ( config . test_ssr ) {
205+ config . test_ssr ( { assert } ) ;
206+ }
207+
204208 if ( config . after_test ) config . after_test ( ) ;
205209
206210 if ( config . show ) {
You can’t perform that action at this time.
0 commit comments