Merge pull request #9135 from dotCooCoo/feat/js-es2015-proxy-reflect

JavaScript: ES2015 realms have Proxy and Reflect
This commit is contained in:
.CooCoo authored and GitHub committed 2026-12-02 11:15:55 -08:00
commit e25243aeb4
10 files changed
+528 -62

No files matched your search

+12 -2
View File
@@ -2882,6 +2882,8 @@ Existing globals with either name are preserved. If a missing global cannot be a
is nonextensible, sealed or frozen, the run fails with an installation error before the script executes.
An empty-handler proxy forwards construction of built-ins, including bound built-ins such as `Map.bind(null)`
and bound typed-array constructors, and reads the proxy's `prototype` for the constructed object.
Typed-array `from` and `of` accept proxy constructors and run their `construct` traps.
A proxy constructor must return a typed array with at least the requested length; otherwise the method throws `TypeError`.
`Reflect.construct` also accepts a distinct constructor
as `newTarget` for `Map`, `Set`, `WeakMap`, `WeakSet` and typed arrays and uses its `prototype` for the new object.
`Map`, `Set`, `WeakMap` and `WeakSet` initialize iterable arguments through the requested prototype's
@@ -2902,20 +2904,25 @@ A conversion or syntax error throws before that prototype getter runs.
membership checks use host collection indexers, including numeric indices and named items.
`JSON.stringify` uses `ToLength` for proxy array lengths and proxy replacer-array lengths, so negative lengths
become zero and fractional lengths are truncated. It checks run limits before allocating array traversal keys
or iterating either list. Array traversal keys count against the heap limit until their writing frame is dropped.
or iterating either list. Array traversal keys count against the heap limit until their writing frame is dropped,
and each distinct name a replacer array keeps counts against it until the call returns.
Its `toJSON` lookup skips host collection indexers through empty-handler proxies
and calls an explicit `get` trap when present.
`concat` and `JSON.parse` reviver traversal also use `ToLength` for proxy arrays. They check lengths before
walking indices or allocating traversal keys. `concat` throws `TypeError` if the combined length exceeds
the maximum safe integer. Reviver traversal keys count against the heap limit until their traversal frame is dropped.
`concat` reads `Symbol.isConcatSpreadable` through proxy `get` traps. A defined value controls whether the object
is spread; an undefined value uses the array check.
In E4X mode, a bare call resolves each scope once. An object binding still checks property membership again
when reading its value; a binding removed between those checks does not select an outer function.
The legacy `Object.prototype.reflect` getter throws `TypeError` for a proxy receiver without enumerating
its properties or calling descriptor traps. Symbol property reads, writes, deletion, descriptor operations
its properties or calling descriptor traps. Its `find` method reads a receiver's own properties without
calling proxy traps, so a proxy receiver throws `TypeError`. Symbol property reads, writes, deletion, descriptor operations
and symbol enumeration on a revoked proxy also throw `TypeError`.
A Symbol key on a proxy goes through the same traps as a string key (`get`, `set`, `has`, `deleteProperty`,
`defineProperty` and `getOwnPropertyDescriptor`), which receive the Symbol itself; without a trap the operation
reaches the target. `Reflect`'s functions take Symbol keys too.
`Object.keys` and `Object.getOwnPropertyNames` keep the target's key order through empty-handler proxies.
For an ordinary object, `Reflect.ownKeys` returns the string keys, then the Symbols in insertion order. Ordinary
targets list array-index keys in ascending order, then other strings in insertion order; an array's `length` precedes
its other non-index strings. A proxy's `ownKeys` trap determines its key order, with strings and Symbols mixed as the
@@ -2930,6 +2937,9 @@ names are rejected; a later getter's exception takes precedence over the duplica
Deleting a binding in a `with` scope calls the proxy's `deleteProperty`
trap without first calling its `getOwnPropertyDescriptor` trap. Target descriptor values and accessors stay
reachable during proxy callbacks, including callbacks that revoke a nested target proxy.
A `with` scope checks `Symbol.unscopables` after finding a property. If that lookup returns an object whose
property for the binding name is truthy, resolution continues in the outer scope. Each read calls a proxy's `get` trap
when its receiver is a proxy.
`Reflect.set` and ordinary assignment ignore invalid numeric indices found on a typed-array prototype
without creating a property on the receiver; when that typed array is the receiver, the value is converted to a
number first. `Object.freeze`, `Object.seal`, `Object.isFrozen` and `Object.isSealed` include a proxy's Symbol