diff --git a/pkg/web_app/lib/src/page_updater.dart b/pkg/web_app/lib/src/page_updater.dart index 2f043ba6e8..dc0874d013 100644 --- a/pkg/web_app/lib/src/page_updater.dart +++ b/pkg/web_app/lib/src/page_updater.dart @@ -44,8 +44,13 @@ Document _update( required bool pushState, required String? url, }) { + // The dark theme preference is encoded in the `` element's `class` + // attributes. We could re-run the initialization, but storing the current + // values and replacing the provided ones is simpler. + final oldClasses = document.body!.className; final doc = DomParser().parseFromString(html, 'text/html'); document.querySelector('body')!.replaceWith(doc.querySelector('body')!); + document.body!.className = oldClasses; _popStateFn!(); if (pushState) { final title = doc.querySelector('title')?.text;