diff --git a/ftd/src/interpreter/things/default.rs b/ftd/src/interpreter/things/default.rs index f46de6eac2..3150d8eea0 100644 --- a/ftd/src/interpreter/things/default.rs +++ b/ftd/src/interpreter/things/default.rs @@ -9562,8 +9562,7 @@ pub fn image_function() -> ftd::interpreter::ComponentDefinition { ftd::interpreter::Argument::default( "fit", ftd::interpreter::Kind::or_type(ftd::interpreter::FTD_IMAGE_FIT) - .into_kind_data() - .into_optional(), + .into_kind_data(), ), ftd::interpreter::Argument::default( "alt", diff --git a/ftd/src/js/element.rs b/ftd/src/js/element.rs index af6987c1ce..4ec3d50cfa 100644 --- a/ftd/src/js/element.rs +++ b/ftd/src/js/element.rs @@ -612,7 +612,7 @@ impl Code { #[derive(Debug)] pub struct Image { pub src: ftd::js::Value, - pub fit: Option, + pub fit: ftd::js::Value, pub alt: Option, pub common: Common, } @@ -632,10 +632,11 @@ impl Image { component_definition.arguments.as_slice(), ) .unwrap(), - fit: ftd::js::value::get_optional_js_value( + fit: ftd::js::value::get_js_value_with_default( "fit", component.properties.as_slice(), component_definition.arguments.as_slice(), + ftd::js::Value::from_str_value("cover"), ), alt: ftd::js::value::get_optional_js_value( "alt", @@ -669,6 +670,14 @@ impl Image { inherited: rdata.inherited_variable_name.to_string(), }, )); + component_statements.push(fastn_js::ComponentStatement::SetProperty( + fastn_js::SetProperty { + kind: fastn_js::PropertyKind::Fit, + value: self.fit.to_set_property_value(doc, rdata), + element_name: kernel.name.to_string(), + inherited: rdata.inherited_variable_name.to_string(), + }, + )); if let Some(ref alt) = self.alt { component_statements.push(fastn_js::ComponentStatement::SetProperty( alt.to_set_property( @@ -679,16 +688,6 @@ impl Image { ), )); } - if let Some(ref fit) = self.fit { - component_statements.push(fastn_js::ComponentStatement::SetProperty( - fit.to_set_property( - fastn_js::PropertyKind::Fit, - doc, - kernel.name.as_str(), - rdata, - ), - )); - } component_statements.extend(self.common.to_set_properties( kernel.name.as_str(), doc, diff --git a/ftd/t/js/13-non-style-properties.html b/ftd/t/js/13-non-style-properties.html index 2248e60cb2..abb58a8658 100644 --- a/ftd/t/js/13-non-style-properties.html +++ b/ftd/t/js/13-non-style-properties.html @@ -16,7 +16,7 @@ -
-- ftd.text: Hello World
+