move ScopeId methods to the runtime (#4723)

* move `ScopeId` methods to runtime methods

* cargo check unused

* wip...

* wip...

* fix consume context

* fix test

* guard hoisted

* fix doc comment
This commit is contained in:
Jonathan Kelley authored and GitHub committed 2025-10-04 01:55:52 -07:00
1 parent c56bac04f4
commit c29cef4ea3
40 files changed
+466 -697

No files matched your search

+3 -3
View File
@@ -1,6 +1,6 @@
use dioxus::dioxus_core::{ElementId, Mutation::*};
use dioxus::prelude::*;
use dioxus_core::generation;
use dioxus_core::{consume_context_from_scope, generation};
#[test]
fn state_shares() {
@@ -31,13 +31,13 @@ fn state_shares() {
dom.mark_dirty(ScopeId::APP);
_ = dom.render_immediate_to_vec();
dom.in_runtime(|| {
assert_eq!(ScopeId::APP.consume_context::<i32>().unwrap(), 1);
assert_eq!(consume_context_from_scope::<i32>(ScopeId::APP).unwrap(), 1);
});
dom.mark_dirty(ScopeId::APP);
_ = dom.render_immediate_to_vec();
dom.in_runtime(|| {
assert_eq!(ScopeId::APP.consume_context::<i32>().unwrap(), 2);
assert_eq!(consume_context_from_scope::<i32>(ScopeId::APP).unwrap(), 2);
});
dom.mark_dirty(ScopeId(ScopeId::APP.0 + 2));
+1 -1
View File
@@ -14,6 +14,6 @@ fn root_node_isnt_null() {
dom.in_runtime(|| {
// The height should be 0
assert_eq!(ScopeId::ROOT.height(), 0);
assert_eq!(scope.height(), 0);
});
}
+1 -1
View File
@@ -272,7 +272,7 @@ fn resolved_to_suspended() {
assert_eq!(out, "rendered 1 times");
dom.in_runtime(|| ScopeId::APP.in_runtime(|| *SUSPENDED.write() = true));
dom.in_scope(ScopeId::APP, || *SUSPENDED.write() = true);
dom.render_suspense_immediate().await;
let out = dioxus_ssr::render(&dom);