use moli_webidl as webidl; #[derive(webidl::WebIdlDictionary)] #[webidl(prefix = "IntersectionObserverInit")] pub struct IntersectionObserverInitMembers where Root: for<'scope> webidl::WebIdlConverter<'scope, Options = ()>, { // The derive converts members in lexical order of their final JavaScript names. #[webidl(default = 0)] pub delay: i32, #[webidl(legacy_nullish, converter = "raw")] pub root: Option, #[webidl(default = "0px")] pub root_margin: String, #[webidl(default = "0px")] pub scroll_margin: String, #[webidl(with = intersection_observer_threshold_member)] pub threshold: Vec, #[webidl(default = false)] pub track_visibility: bool, } fn intersection_observer_threshold_member<'s>( scope: &mut v8::PinScope<'s, '_>, object: v8::Local<'s, v8::Object>, member: &'static str, ) -> Result, webidl::WebIdlError> { let context = webidl::Context::member("IntersectionObserverInit", member); let Some(value) = webidl::optional_member::>(scope, object, member, context)? else { return Ok(vec![0.0]); }; // Convert the union at its dictionary position, reading @@iterator once. if let Some(sequence) = webidl::convert_optional_sequence::(scope, value, context, &())? { Ok(sequence.0.into_iter().map(|value| value.0).collect()) } else { Ok(vec![ webidl::convert::(scope, value, context)?.0, ]) } }