ljharb / es-abstract

ECMAScript spec abstract operations.
MIT License
114 stars 30 forks source link

[Fix] `helpers/OwnPropertyKeys`: Use `Reflect.ownKeys(…)` if available #91

Closed ExE-Boss closed 4 years ago

ExE-Boss commented 4 years ago

This is because Object.getOwnPropertyNames(target) and Object.getOwnPropertySymbols(target) both invoke target.[[OwnPropertyKeys]](), which Reflect.ownKeys(target) does only once, which is observable when using Proxies.

This will also make the OwnPropertyKeys helper throw a TypeError for non‑object targets in all ECMAScript environments, instead of just in ES5 environments.


review?(@ljharb)