Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

property dependency fixes for region -> text -> role #1435

Merged
merged 3 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 40 additions & 11 deletions ftd/src/js/element.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1160,18 +1160,16 @@ impl Text {
let mut component_statements = vec![];
let kernel = create_element(fastn_js::ElementKind::Text, parent, index, rdata);
component_statements.push(fastn_js::ComponentStatement::CreateKernel(kernel.clone()));
component_statements.extend(self.common.to_set_properties(
component_statements.extend(self.common.to_set_properties_with_text(
kernel.name.as_str(),
doc,
rdata,
));
component_statements.push(fastn_js::ComponentStatement::SetProperty(
fastn_js::SetProperty {
fastn_js::ComponentStatement::SetProperty(fastn_js::SetProperty {
kind: fastn_js::PropertyKind::StringValue,
value: self.text.to_set_property_value(doc, rdata),
element_name: kernel.name.to_string(),
inherited: rdata.inherited_variable_name.to_string(),
},
}),
));
component_statements.extend(self.text_common.to_set_properties(
kernel.name.as_str(),
Expand Down Expand Up @@ -2446,7 +2444,7 @@ impl Common {
}
}

pub fn to_set_properties(
pub fn to_set_properties_without_role(
&self,
element_name: &str,
doc: &ftd::interpreter::TDoc,
Expand Down Expand Up @@ -2934,11 +2932,6 @@ impl Common {
),
));
}
if let Some(ref role) = self.role {
component_statements.push(fastn_js::ComponentStatement::SetProperty(
role.to_set_property(fastn_js::PropertyKind::Role, doc, element_name, rdata),
));
}
if let Some(ref opacity) = self.opacity {
component_statements.push(fastn_js::ComponentStatement::SetProperty(
opacity.to_set_property(fastn_js::PropertyKind::Opacity, doc, element_name, rdata),
Expand Down Expand Up @@ -3046,6 +3039,42 @@ impl Common {
}
component_statements
}

pub fn to_set_properties_with_text(
&self,
element_name: &str,
doc: &ftd::interpreter::TDoc,
rdata: &ftd::js::ResolverData,
text_component_statement: fastn_js::ComponentStatement,
) -> Vec<fastn_js::ComponentStatement> {
// Property dependencies
// Role <- Text (Role for post_markdown_process) <- Region(Headings need text for auto ids)
let mut component_statements = vec![];
if let Some(ref role) = self.role {
component_statements.push(fastn_js::ComponentStatement::SetProperty(
role.to_set_property(fastn_js::PropertyKind::Role, doc, element_name, rdata),
));
}
component_statements.push(text_component_statement);
component_statements.extend(self.to_set_properties_without_role(element_name, doc, rdata));
component_statements
}

pub fn to_set_properties(
&self,
element_name: &str,
doc: &ftd::interpreter::TDoc,
rdata: &ftd::js::ResolverData,
) -> Vec<fastn_js::ComponentStatement> {
let mut component_statements = vec![];
component_statements.extend(self.to_set_properties_without_role(element_name, doc, rdata));
if let Some(ref role) = self.role {
component_statements.push(fastn_js::ComponentStatement::SetProperty(
role.to_set_property(fastn_js::PropertyKind::Role, doc, element_name, rdata),
));
}
component_statements
}
}

impl ftd::interpreter::Event {
Expand Down
16 changes: 8 additions & 8 deletions ftd/t/js/01-basic-module.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions ftd/t/js/01-basic.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions ftd/t/js/02-property.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading