Browse Source

Implement `JSON[ @@toStringTag ]` (#1224)

pull/1237/head
Halid Odat 4 years ago committed by GitHub
parent
commit
26b62234cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      boa/src/builtins/json/mod.rs

5
boa/src/builtins/json/mod.rs

@ -41,7 +41,12 @@ impl BuiltIn for Json {
fn init(context: &mut Context) -> (&'static str, Value, Attribute) { fn init(context: &mut Context) -> (&'static str, Value, Attribute) {
let _timer = BoaProfiler::global().start_event(Self::NAME, "init"); let _timer = BoaProfiler::global().start_event(Self::NAME, "init");
let to_string_tag = context.well_known_symbols().to_string_tag_symbol();
let attribute = Attribute::READONLY | Attribute::NON_ENUMERABLE | Attribute::CONFIGURABLE;
let json_object = ObjectInitializer::new(context) let json_object = ObjectInitializer::new(context)
.property(to_string_tag, "JSON", attribute)
.function(Self::parse, "parse", 2) .function(Self::parse, "parse", 2)
.function(Self::stringify, "stringify", 3) .function(Self::stringify, "stringify", 3)
.build(); .build();

Loading…
Cancel
Save