diff --git a/src/conversions.rs b/src/conversions.rs index a6065b055..2866570e3 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -622,6 +622,18 @@ impl ToJSValConvertible for *mut JSObject { } } +// https://heycam.github.io/webidl/#es-object +impl FromJSValConvertible for *mut JSObject { + type Config = (); + #[inline] + unsafe fn from_jsval(_cx: *mut JSContext, + val: HandleValue, + _option: ()) + -> Result, ()> { + Ok(ConversionResult::Success(val.to_object_or_null())) + } +} + // https://heycam.github.io/webidl/#es-object impl ToJSValConvertible for NonZero<*mut JSObject> { #[inline] @@ -630,3 +642,15 @@ impl ToJSValConvertible for NonZero<*mut JSObject> { maybe_wrap_object_value(cx, rval); } } + +// https://heycam.github.io/webidl/#es-object +impl FromJSValConvertible for NonZero<*mut JSObject> { + type Config = (); + #[inline] + unsafe fn from_jsval(_cx: *mut JSContext, + val: HandleValue, + _option: ()) + -> Result>, ()> { + Ok(ConversionResult::Success(NonZero::new(val.to_object()))) + } +}