js-sys: Add bindings for Symbol.unscopables

This commit is contained in:
Nick Fitzgerald 2018-08-10 13:23:17 -07:00
parent 016449ab3c
commit 7af4e62d99
2 changed files with 13 additions and 0 deletions

View File

@ -3203,6 +3203,14 @@ extern "C" {
#[wasm_bindgen(method, js_name = toString)]
pub fn to_string(this: &Symbol) -> JsString;
/// The Symbol.unscopables well-known symbol is used to specify an object
/// value of whose own and inherited property names are excluded from the
/// with environment bindings of the associated object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/unscopables
#[wasm_bindgen(static_method_of = Symbol, getter, structural)]
pub fn unscopables() -> Symbol;
/// The valueOf() method returns the primitive value of a Symbol object.
///
/// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/valueOf

View File

@ -99,6 +99,11 @@ fn to_string() {
assert_eq!(gensym("desc".into()).to_string(), "Symbol(desc)");
}
#[wasm_bindgen_test]
fn unscopables() {
assert_eq!(Symbol::unscopables().to_string(), "Symbol(Symbol.unscopables)");
}
#[wasm_bindgen_test]
fn value_of() {
let a = Symbol::for_("foo");