tvcutsem/harmony-reflect

Warning instead of throwing a TypeError for getOwnPropertyNames deprecated trap

ognjenb opened this issue · 7 comments

Hello,

Currently lots of libs and browsers with Proxy object still call the getOwnPropertyNames method. It would be good for the shim to show a warning and call ownKeys instead of throwing an error, as currently it stops execution.

What do you think?

Thank you!

Sounds reasonable, and should be backward-compat. I should be able to fix that in one of the coming days. Watch this space :)

Thank you! Temporary I created a fork for my package.json.

I've been thinking more about this and I'm wondering how exactly it is that this trap can still be invoked when using this shim. Normally the only method that calls the getOwnPropertyNames trap would be Object.getOwnPropertyNames, but my shim patches that method to call ownKeys instead.

Can you provide an example scenario where you still run into this trap being called even when the harmony-reflect library is loaded?

Ok. So in my case, I am proxifying a simple object and then at some point persisting that proxy wrapped object using PouchDB's put method, which calls internally Object. getOwnPropertyNames as I see.

I created a simple example here:
https://github.com/ognjenb/proxyPersistWithPouch

I see. Thanks for providing the isolated test case. The issue is that external libraries, who are not using this shim, are using the unpatched versions of the Object.* methods and thus still using the old API.

Since the fix is easy enough and doesn't disrupt anything else, I'll just add the deprecation warning and fallback to ownKeys.

Fixed in v1.2.1!

Thank you!