jaspr
jaspr copied to clipboard
Client StatefulComponent fails at runtime when used with Jaspr 0.12.0, index.template.html and no div wrapped Router
Description
Apps with StatefulComponent
client fail at runtime when using the following setup:
- Jaspr
0.12.0
-
runApp(Document.template(name: 'index',child: App()));
- an
App()
where aRouter
is yielded without adiv()
component outside it.
When the StatefulComponent
fails, the following stacktrace is shown in browser console:
Uncaught (in promise) Error: Assertion failed: org-dartlang-app:///packages/jaspr/src/browser/dom_render_object.dart:209:14
parentNode is html.Element
is not true
at Object.throw_ [as throw] (errors.dart:297:3)
at Object.assertFailed (errors.dart:38:3)
at dom_render_object.DomRenderObject.new.attach (dom_render_object.dart:209:24)
at framework.DomElement.new.attachRenderObject (render_object.dart:75:5)
at framework.BuildOwner.new.performRebuildOn (build_owner.dart:91:10)
at framework.DomElement.new.rebuild (framework.dart:796:5)
at [_firstBuild] (multi_child_element.dart:37:5)
at [_firstBuild] (render_object.dart:59:11)
at framework.DomElement.new.mount (multi_child_element.dart:31:5)
at framework.StatefulElement.new.inflateComponent (framework.dart:450:13)
at framework.StatefulElement.new.updateChild (framework.dart:316:18)
at framework.StatefulElement.new.updateChildren (multi_child_element.dart:197:32)
at framework.StatefulElement.new.performRebuild (multi_child_element.dart:69:17)
at framework.StatefulElement.new.performRebuild (stateful_component.dart:684:11)
at framework.BuildOwner.new.performRebuildOn (build_owner.dart:84:27)
at framework.StatefulElement.new.rebuild (framework.dart:796:5)
at [_firstBuild] (multi_child_element.dart:37:5)
at [_firstBuild] (stateful_component.dart:640:11)
at framework.StatefulElement.new.mount (multi_child_element.dart:31:5)
at framework._RootElement.new.inflateComponent (framework.dart:450:13)
at framework._RootElement.new.updateChild (framework.dart:316:18)
at framework._RootElement.new.performRebuild (single_child_element.dart:61:14)
at framework.BuildOwner.new.performRebuildOn (build_owner.dart:84:27)
at framework._RootElement.new.rebuild (framework.dart:796:5)
at [_firstBuild] (single_child_element.dart:31:5)
at [_firstBuild] (render_object.dart:59:11)
at framework._RootElement.new.mount (single_child_element.dart:25:5)
at performInitialBuild (build_owner.dart:13:12)
at performInitialBuild.next (
Steps To Reproduce
- Ensure Jaspr is updated to version 0.11.1
- Clone example minimal project at https://github.com/ponderMuse/jaspr_index_template_issue
- jaspr clean
- jaspr build
- jaspr serve
Doctor Output
[✓] Jaspr CLI (Version 0.12.0) • Dart Version 3.3.0 (stable) (Tue Feb 13 10:25:19 2024 +0000) on "linux_x64" at /mnt/data/flutter/bin/cache/dart-sdk/bin/dart • Running on linux Linux 5.15.0-102-generic #112-Ubuntu SMP Tue Mar 5 16:50:32 UTC 2024 - Locale en_GB.UTF-8 • Analytics: Enabled
[✓] Current Project • Dependencies on core packages: • jaspr: Missing Dependency • Rendering mode: server • Uses jaspr compilers: false • Uses flutter embedding: false
Expected Behavior
The StatefulComponent
should wait 5 seconds and display a message when the app is run.
Additional Context
In App.dart
I have included a code snippet which does wrap Router
with a div()
which is commented out that can be swapped in/out to see the StatefulComponent
working/not working.
Not sure if the div()
outside Router
is required or NOT but I can say that the code without div()
outside Router
worked fine in Jaspr 0.10.0
using an index.html
file, works okay in 0.12.0
when NOT using index.template.html
file (i.e. works okay when using programmatic root Document()
).
Working on a fix
Fixed in 0.13.0