Skip to content

js-sys: Add extends attributes for js_sys::Number #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 9, 2018

Conversation

bokuweb
Copy link
Contributor

@bokuweb bokuweb commented Aug 9, 2018

Part of #670

@bokuweb bokuweb force-pushed the number-extends-attributes branch from 516baf0 to f471aff Compare August 9, 2018 00:43
Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bokuweb!

Just one thing before we can merge this, see comment below.

use wasm_bindgen::JsValue;
use wasm_bindgen_test::*;
use js_sys::*;

#[wasm_bindgen_test]
fn number_inheritance() {
let number: i32 = 10;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be:

let number = Number::new(&JsValue::from(10));

Note that if you open a JS console:

> 10 instanceof Number
false
> new Number(10) instanceof Number
true

JS has a distinction between Number objects and its number values, which is a bit tricky!

@bokuweb bokuweb force-pushed the number-extends-attributes branch from f471aff to 42e02f7 Compare August 9, 2018 01:10
@bokuweb
Copy link
Contributor Author

bokuweb commented Aug 9, 2018

Thanks for your quick response :) On this occasion I will learn about wasm-bindgen.

Copy link
Member

@fitzgen fitzgen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @bokuweb!

@fitzgen fitzgen merged commit bd62fdb into rustwasm:master Aug 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants