mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 12:17:44 +00:00
LibJS: Accept symbol property in ObjectPrototype::hasOwnProperty
This is used by discord.com and allowed by the specification (https://tc39.es/ecma262/#sec-topropertykey)
This commit is contained in:
parent
2381b19719
commit
fff7aceb9d
2 changed files with 7 additions and 2 deletions
|
@ -66,10 +66,10 @@ JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::has_own_property)
|
||||||
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
auto* this_object = vm.this_value(global_object).to_object(global_object);
|
||||||
if (!this_object)
|
if (!this_object)
|
||||||
return {};
|
return {};
|
||||||
auto name = vm.argument(0).to_string(global_object);
|
auto string_or_symbol = StringOrSymbol::from_value(global_object, vm.argument(0));
|
||||||
if (vm.exception())
|
if (vm.exception())
|
||||||
return {};
|
return {};
|
||||||
return Value(this_object->has_own_property(name));
|
return Value(this_object->has_own_property(string_or_symbol));
|
||||||
}
|
}
|
||||||
|
|
||||||
JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
|
JS_DEFINE_NATIVE_FUNCTION(ObjectPrototype::to_string)
|
||||||
|
|
|
@ -10,4 +10,9 @@ test("basic functionality", () => {
|
||||||
o.undefined = 2;
|
o.undefined = 2;
|
||||||
expect(o.hasOwnProperty()).toBeTrue();
|
expect(o.hasOwnProperty()).toBeTrue();
|
||||||
expect(o.hasOwnProperty(undefined)).toBeTrue();
|
expect(o.hasOwnProperty(undefined)).toBeTrue();
|
||||||
|
|
||||||
|
var testSymbol = Symbol("real");
|
||||||
|
o[testSymbol] = 3;
|
||||||
|
expect(o.hasOwnProperty(testSymbol)).toBeTrue();
|
||||||
|
expect(o.hasOwnProperty(Symbol("fake"))).toBeFalse();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue