diff --git a/crates/js-sys/src/lib.rs b/crates/js-sys/src/lib.rs index 8af6e90065b..d923a7bbb8b 100644 --- a/crates/js-sys/src/lib.rs +++ b/crates/js-sys/src/lib.rs @@ -4444,8 +4444,8 @@ pub mod Intl { /// object. /// /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Collator/compare) - #[wasm_bindgen(method, getter, js_class = "Intl.Collator")] - pub fn compare(this: &Collator) -> Function; + #[wasm_bindgen(method, js_class = "Intl.Collator")] + pub fn compare(this: &Collator, string1: &str, string2: &str) -> i32; /// The `Intl.Collator.prototype.resolvedOptions()` method returns a new /// object with properties reflecting the locale and collation options @@ -4488,8 +4488,8 @@ pub mod Intl { /// Intl.DateTimeFormat object. /// /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat/format) - #[wasm_bindgen(method, getter, js_class = "Intl.DateTimeFormat")] - pub fn format(this: &DateTimeFormat) -> Function; + #[wasm_bindgen(method, js_class = "Intl.DateTimeFormat")] + pub fn format(this: &DateTimeFormat, date: &Date) -> JsString; /// The `Intl.DateTimeFormat.prototype.formatToParts()` method allows locale-aware /// formatting of strings produced by DateTimeFormat formatters. @@ -4539,8 +4539,8 @@ pub mod Intl { /// NumberFormat object. /// /// [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/NumberFormat/format) - #[wasm_bindgen(method, getter, js_class = "Intl.NumberFormat")] - pub fn format(this: &NumberFormat) -> Function; + #[wasm_bindgen(method, js_class = "Intl.NumberFormat")] + pub fn format(this: &NumberFormat, number: f64) -> JsString; /// The `Intl.Numberformat.prototype.formatToParts()` method allows locale-aware /// formatting of strings produced by NumberTimeFormat formatters. diff --git a/crates/js-sys/tests/wasm/Intl.rs b/crates/js-sys/tests/wasm/Intl.rs index 427ea00a5da..396a4a2624b 100644 --- a/crates/js-sys/tests/wasm/Intl.rs +++ b/crates/js-sys/tests/wasm/Intl.rs @@ -30,7 +30,9 @@ fn collator() { let opts = Object::new(); let c = Intl::Collator::new(&locales, &opts); - assert!(c.compare().is_instance_of::()); + assert_eq!(c.compare("a", "b"), -1); + assert_eq!(c.compare("a", "a"), 0); + assert_eq!(c.compare("b", "a"), 1); assert!(c.resolved_options().is_instance_of::()); let a = Intl::Collator::supported_locales_of(&locales, &opts); @@ -55,7 +57,7 @@ fn date_time_format() { let epoch = Date::new(&JsValue::from(0)); let c = Intl::DateTimeFormat::new(&locales, &opts); - assert!(c.format().is_instance_of::()); + assert!(c.format(&epoch).is_string()); assert!(c.format_to_parts(&epoch).is_instance_of::()); assert!(c.resolved_options().is_instance_of::()); @@ -80,7 +82,7 @@ fn number_format() { let opts = Object::new(); let n = Intl::NumberFormat::new(&locales, &opts); - assert!(n.format().is_instance_of::()); + assert_eq!(n.format(42.5), JsString::from("42.5")); assert!(n.format_to_parts(42.5).is_instance_of::()); assert!(n.resolved_options().is_instance_of::());