diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py index b828ccb74bd..adebf601568 100644 --- a/components/script/dom/bindings/codegen/CodegenRust.py +++ b/components/script/dom/bindings/codegen/CodegenRust.py @@ -887,23 +887,12 @@ def getJSToNativeConversionInfo(type, descriptorProvider, failureCode=None, if type.nullable(): declType = CGWrapper(declType, pre="Option<", post=">") - template = "" - if type.isFloat() and not type.isUnrestricted(): - template = ( - "match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n" - " Ok(v) => v,\n" - " Err(_) => {\n" - " throw_type_error(cx, \"this argument is not a finite floating-point value\");\n" - " %s\n" - " }\n" - "}" % exceptionCode) - else: - #XXXjdm support conversionBehavior here - template = ( - "match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n" - " Ok(v) => v,\n" - " Err(_) => { %s }\n" - "}" % exceptionCode) + #XXXjdm support conversionBehavior here + template = ( + "match FromJSValConvertible::from_jsval(cx, ${val}, ()) {\n" + " Ok(v) => v,\n" + " Err(_) => { %s }\n" + "}" % exceptionCode) if defaultValue is not None: if isinstance(defaultValue, IDLNullValue): diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index f027b8b8504..eb6d7d60680 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -33,6 +33,7 @@ //! | union types | `T` | use dom::bindings::codegen::PrototypeList; +use dom::bindings::error::throw_type_error; use dom::bindings::js::{JSRef, Root, Unrooted}; use dom::bindings::num::Finite; use dom::bindings::str::{ByteString, USVString}; @@ -288,7 +289,10 @@ impl> FromJSValConvertible for Finite let result = try!(FromJSValConvertible::from_jsval(cx, value, option)); match Finite::new(result) { Some(v) => Ok(v), - None => Err(()), + None => { + throw_type_error(cx, "this argument is not a finite floating-point value"); + Err(()) + }, } } }