New reconciler finally renders, just need to do some cleanup then can finally move on
This commit is contained in:
parent
da96abff6a
commit
2a73b399d9
6 changed files with 56 additions and 38 deletions
|
|
@ -32,14 +32,12 @@ impl RSX {
|
|||
pub fn node(
|
||||
tag: &'static str,
|
||||
create_fn: fn(key: ComponentKey) -> Box<Component>,
|
||||
props: Props,
|
||||
children: Vec<RSX>
|
||||
props: Props
|
||||
) -> RSX {
|
||||
RSX::VirtualNode(VirtualNode {
|
||||
tag: tag,
|
||||
create_component_fn: create_fn,
|
||||
props: props,
|
||||
children: children
|
||||
props: props
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -37,15 +37,31 @@ pub struct Props {
|
|||
}
|
||||
|
||||
impl Props {
|
||||
pub fn new(key: String, styles: StylesList, attributes: HashMap<&'static str, AttributeType>) -> Props {
|
||||
/// A helper method for constructing Properties.
|
||||
pub fn new(
|
||||
key: String,
|
||||
styles: StylesList,
|
||||
attributes: HashMap<&'static str, AttributeType>,
|
||||
children: Vec<RSX>
|
||||
) -> Props {
|
||||
Props {
|
||||
attributes: attributes,
|
||||
children: vec![],
|
||||
children: children,
|
||||
key: key,
|
||||
styles: styles
|
||||
}
|
||||
}
|
||||
|
||||
/// A helper method used for constructing root-level Properties.
|
||||
pub(crate) fn root(children: Vec<RSX>) -> Props {
|
||||
Props {
|
||||
attributes: HashMap::new(),
|
||||
children: children,
|
||||
key: "".into(),
|
||||
styles: "root".into()
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns a Vec of RSX nodes, which are really just cloned pointers for the most part.
|
||||
pub fn children(&self) -> Vec<RSX> {
|
||||
self.children.clone()
|
||||
|
|
|
|||
|
|
@ -24,10 +24,7 @@ pub struct VirtualNode {
|
|||
/// ownership of a VirtualNode.
|
||||
///
|
||||
/// This aspect of functionality may be pulled in a later release if it causes too many issues.
|
||||
pub props: Props,
|
||||
|
||||
///
|
||||
pub children: Vec<RSX>
|
||||
pub props: Props
|
||||
}
|
||||
|
||||
impl Display for VirtualNode {
|
||||
|
|
@ -35,7 +32,7 @@ impl Display for VirtualNode {
|
|||
fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
|
||||
write!(f, "<{}>", self.tag)?;
|
||||
|
||||
for child in &self.children {
|
||||
for child in &self.props.children {
|
||||
write!(f, "{:?}", child)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue