зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1711872 - Implement Object.hasOwn proposal; r=evilpie
Differential Revision: https://phabricator.services.mozilla.com/D115483
This commit is contained in:
Родитель
3a3d434baa
Коммит
81d2466f6e
|
@ -2109,6 +2109,10 @@ static const JSFunctionSpec object_static_methods[] = {
|
|||
JS_FN("seal", obj_seal, 1, 0),
|
||||
JS_FN("isSealed", obj_isSealed, 1, 0),
|
||||
JS_SELF_HOSTED_FN("fromEntries", "ObjectFromEntries", 1, 0),
|
||||
/* Proposal */
|
||||
#ifdef NIGHTLY_BUILD
|
||||
JS_SELF_HOSTED_FN("hasOwn", "ObjectHasOwn", 2, 0),
|
||||
#endif
|
||||
JS_FS_END};
|
||||
|
||||
static JSObject* CreateObjectConstructor(JSContext* cx, JSProtoKey key) {
|
||||
|
|
|
@ -323,3 +323,12 @@ function ObjectFromEntries(iter) {
|
|||
return obj;
|
||||
}
|
||||
|
||||
// Proposal https://github.com/tc39/proposal-accessible-object-hasownproperty
|
||||
// 1. Object.hasOwn ( O, P )
|
||||
function ObjectHasOwn(O, P) {
|
||||
// Step 1.
|
||||
var obj = ToObject(O);
|
||||
// Step 2-3.
|
||||
return hasOwn(P, obj);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,6 @@ skip-if(!this.hasOwnProperty("Intl")) include test262/intl402/jstests.list
|
|||
skip-if(!this.hasOwnProperty("Atomics")) include test262/built-ins/Atomics/jstests.list
|
||||
skip-if(!this.hasOwnProperty("SharedArrayBuffer")) include test262/built-ins/SharedArrayBuffer/jstests.list
|
||||
|
||||
|
||||
#####################################
|
||||
# Test262 tests disabled on browser #
|
||||
#####################################
|
||||
|
@ -1018,3 +1017,4 @@ shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/le
|
|||
shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/name.js
|
||||
shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/take.js
|
||||
shell-option(--enable-iterator-helpers) script non262/Iterator/prototype/take/take-more-than-available.js
|
||||
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
// |reftest| skip-if(!Object.hasOwn)
|
||||
/*
|
||||
* Any copyright is dedicated to the Public Domain.
|
||||
* https://creativecommons.org/publicdomain/zero/1.0/
|
||||
*/
|
||||
|
||||
assertEq(Object.hasOwn({}, "any"), false);
|
||||
assertThrowsInstanceOf(() => Object.hasOwn(null, "any"), TypeError);
|
||||
|
||||
var x = { test: 'test value'}
|
||||
var y = {}
|
||||
var z = Object.create(x);
|
||||
|
||||
assertEq(Object.hasOwn(x, "test"), true);
|
||||
assertEq(Object.hasOwn(y, "test"), false);
|
||||
assertEq(Object.hasOwn(z, "test"), false);
|
||||
|
||||
if (typeof reportCompare === "function")
|
||||
reportCompare(true, true);
|
|
@ -229,6 +229,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
|
|||
"preventExtensions", "freeze", "fromEntries", "isFrozen", "seal",
|
||||
"isSealed", "assign", "getPrototypeOf", "values",
|
||||
"entries", "isExtensible"]);
|
||||
if (isNightlyBuild) {
|
||||
gConstructorProperties['Object'].push("hasOwn");
|
||||
}
|
||||
gPrototypeProperties['Array'] =
|
||||
["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push",
|
||||
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",
|
||||
|
|
Загрузка…
Ссылка в новой задаче