From 0eed8878ffad8badb5e59dda9a8a662d2c38f13a Mon Sep 17 00:00:00 2001 From: Keavon Chambers Date: Sun, 1 Nov 2020 01:45:01 -0700 Subject: [PATCH] Update the text in window_dom.rs --- src/window_dom.rs | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/src/window_dom.rs b/src/window_dom.rs index e4ec35b1..20999167 100644 --- a/src/window_dom.rs +++ b/src/window_dom.rs @@ -21,12 +21,12 @@ impl<'a> WindowDom<'a> { fn build_dom_from_component( root_component: &str, layout_attributes: &LayoutAttributes, - parameters: &Vec, + props: &Vec, loaded_components: &'a ResourceCache, ) -> rctree::Node { // Instantiate the DOM node and put it in a tree node let component = loaded_components.get(root_component).unwrap(); - let dom_node = DomNode::from_component(component, layout_attributes, parameters); + let dom_node = DomNode::from_component(component, layout_attributes, props); let mut tree = rctree::Node::new(dom_node); // Recursively build the child `DomNode` tree node instances @@ -39,7 +39,7 @@ impl<'a> WindowDom<'a> { let component_name = LayoutSystem::component_name((namespace, name)); // Recursively build the child `DomNode` component instance - Self::build_dom_from_component(&component_name[..], &child.layout_arguments, &child.user_arguments, loaded_components) + Self::build_dom_from_component(&component_name[..], &child.layout, &child.props, loaded_components) }) .collect::>(); @@ -56,11 +56,11 @@ impl<'a> WindowDom<'a> { pub struct DomNode { pub cache_name: String, pub layout_attributes: LayoutAttributes, - pub variable_bindings: HashMap>, + pub variable_bindings: HashMap>, } impl DomNode { - pub fn new(cache_name: String, layout_attributes: LayoutAttributes, variable_bindings: HashMap>) -> Self { + pub fn new(cache_name: String, layout_attributes: LayoutAttributes, variable_bindings: HashMap>) -> Self { Self { cache_name, layout_attributes, @@ -68,36 +68,36 @@ impl DomNode { } } - pub fn from_component(component: &FlatComponent, layout_attributes: &LayoutAttributes, parameters: &Vec) -> Self { + pub fn from_component(component: &FlatComponent, layout_attributes: &LayoutAttributes, props: &Vec) -> Self { // Cached name of the loaded component let (namespace, name) = &component.own_info.name; let cache_name = LayoutSystem::component_name((&namespace[..], &name[..])); - // Every VARIABLE_NAME binding defined as a parameter on this component + // Every VARIABLE_NAME binding defined in the prop definitions on this component let mut variable_bindings = component .own_info - .parameters + .prop_definitions .iter() - .map(|parameter| { + .map(|prop_definition| { ( - // HashMap key is the parameter name - parameter.name.clone(), - // HashMap value is the parameter's defined default value - parameter + // HashMap key is the prop name + prop_definition.variable_name.clone(), + // HashMap value is the prop definition's default value + prop_definition .type_sequence_default .iter() - .map(|value| TypeValueOrArgument::TypeValue(value.clone())) + .map(|value| TypedValueOrVariableName::TypedValue(value.clone())) .collect::>(), ) }) .collect::>(); - // Overwrite the defaults for given parameters - for parameter in parameters { - if !variable_bindings.contains_key(¶meter.name[..]) { - panic!("Invalid argument {} given to the {} component", parameter.name, cache_name); + // Overwrite the default values for the provided props + for prop in props { + if !variable_bindings.contains_key(&prop.name[..]) { + panic!("Invalid argument {} given to the {} component", prop.name, cache_name); } - variable_bindings.insert(parameter.name.clone(), parameter.value.clone()); + variable_bindings.insert(prop.name.clone(), prop.value_sequence.clone()); } Self::new(cache_name, layout_attributes.clone(), variable_bindings)