@@ -11,12 +11,13 @@ import '../foundation/binding.dart';
1111import '../foundation/constants.dart' ;
1212import '../framework/framework.dart' ;
1313import 'dom_render_object.dart' ;
14- import 'utils.dart' ;
1514
1615/// Global component binding for the client.
1716class ClientAppBinding extends AppBinding with ComponentsBinding {
1817 ClientAppBinding () {
19- initializeEvents ();
18+ if (kDebugMode) {
19+ _debugInitializeEvents ();
20+ }
2021 }
2122
2223 @override
@@ -70,25 +71,25 @@ class ClientAppBinding extends AppBinding with ComponentsBinding {
7071 web.console.error ('Error while building ${element .component .runtimeType }:\n $error \n\n $stackTrace ' .toJS);
7172 }
7273
73- SseClient ? _eventsClient ;
74+ SseClient ? _debugEventsClient ;
7475
75- void initializeEvents () {
76- if (_eventsClient != null ) return ;
76+ void _debugInitializeEvents () {
77+ if (_debugEventsClient != null ) return ;
7778
78- _eventsClient = SseClient (r'/$jasprEventsHandler' );
79- _eventsClient ! .stream.listen (
79+ _debugEventsClient = SseClient (r'/$jasprEventsHandler' );
80+ _debugEventsClient ! .stream.listen (
8081 (event) {
8182 final data = jsonDecode (event);
8283 if (data case ['ReloadRequest' ]) {
8384 _reloadPage ();
8485 }
8586 },
8687 onDone: () {
87- _eventsClient ! .close ();
88- _eventsClient = null ;
88+ _debugEventsClient ! .close ();
89+ _debugEventsClient = null ;
8990 },
9091 );
91- _eventsClient ! .sink.add (jsonEncode (['RouteInfo' , web.window.location.pathname]));
92+ _debugEventsClient ! .sink.add (jsonEncode (['RouteInfo' , web.window.location.pathname]));
9293 }
9394
9495 void _reloadPage ([String ? path]) async {
@@ -114,8 +115,7 @@ class ClientAppBinding extends AppBinding with ComponentsBinding {
114115 final newNode = _attachTarget == 'body' ? body : body.querySelector (_attachTarget)! ;
115116
116117 final rootRenderObject = rootElement! .renderObject as RootDomRenderObject ;
117- rootRenderObject.node = newNode;
118- rootRenderObject.toHydrate = [...newNode.childNodes.toIterable ()];
118+ rootRenderObject.setRootNode (newNode);
119119 rootElement! .owner.performReload (rootElement! );
120120
121121 web.document.body! .replaceWith (body);
0 commit comments