Skip to content

Commit 78d4204

Browse files
authored
Introduce explicit internal datastructures modeling dom state (#2330)
* detach destructures now * add failing keyed-list issue * crude port to the new bundle infrastructure * port over the infrastructure the new bcomp is especially nice and lost a few unwraps owed to not having to reserve space for a scope before rendering. Note also that bsuspense has been slimmed a bit, storing the suspended flag implicitly in the state. some naming is not perfect yet and has to be adjusted still. * mass rename: apply -> reconcile * get rid of move_before in favor of shift * generate id directly when creating a new scope * bundle for text nodes * work on naming: ancestor -> bundle * slightly optimize list reconciler, add doccomments * address review * add internal documentation * address review comments rename fields in bsuspense convert to gloo::events * move even more stuff into dom_bundle to scope exports - app_handle and layout_tests are now in there - items are publically re-exported in crate::dom_bundle - dom_bundle itself is private - btag and bcomp get their own submodules - bcomp now contains the lifecycle and scope impls * move replace into Reconcilable * move lifecycle and scope back into html as per review * move back Value and InputFields into html * actually only type-check format args in production * fix documentation link * move btag_impl up into containing module * shift comps immediately shifting the rendered Nodes does not tie into the lifecycle, as such it can happen immediately * use list-bundle in tag-bundle * fix cargo make tests * improve 05_swap benchmark * fix a blunder where I swapped operands * fix naming of BNode variants
1 parent 221b4df commit 78d4204

32 files changed

Lines changed: 5604 additions & 4946 deletions

Makefile.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ dependencies = ["test"]
8282
[tasks.test]
8383
private = true
8484
command = "cargo"
85-
args = ["test", "--all-targets", "--workspace", "--exclude", "website-test"]
85+
args = ["test", "--all-targets"]
8686

8787
[tasks.doc-test-flow]
8888
private = true
Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
//! This module contains the `App` struct, which is used to bootstrap
2-
//! a component in an isolated scope.
1+
//! [AppHandle] contains the state Yew keeps to bootstrap a component in an isolated scope.
32
4-
use std::ops::Deref;
5-
6-
use crate::html::{BaseComponent, NodeRef, Scope, Scoped};
7-
use std::rc::Rc;
3+
use super::{ComponentRenderState, Scoped};
4+
use crate::html::{BaseComponent, Scope};
5+
use crate::NodeRef;
6+
use std::{ops::Deref, rc::Rc};
87
use web_sys::Element;
98

109
/// An instance of an application.
1110
#[derive(Debug)]
1211
pub struct AppHandle<COMP: BaseComponent> {
1312
/// `Scope` holder
14-
pub(crate) scope: Scope<COMP>,
13+
scope: Scope<COMP>,
1514
}
1615

1716
impl<COMP> AppHandle<COMP>
@@ -27,14 +26,17 @@ where
2726
let app = Self {
2827
scope: Scope::new(None),
2928
};
29+
let node_ref = NodeRef::default();
30+
let initial_render_state =
31+
ComponentRenderState::new(element, NodeRef::default(), &node_ref);
3032
app.scope
31-
.mount_in_place(element, NodeRef::default(), NodeRef::default(), props);
33+
.mount_in_place(initial_render_state, node_ref, props);
3234

3335
app
3436
}
3537

3638
/// Schedule the app for destruction
37-
pub fn destroy(mut self) {
39+
pub fn destroy(self) {
3840
self.scope.destroy(false)
3941
}
4042
}

0 commit comments

Comments
 (0)