Property checking in host objects
Bug Description
The behaviour described below has been noticed by us since many years now but we never had an issue with it until now. Now that we run three.js on top of host objects, we have less flexibility on how they could behave. I also acknowledge that this wouldn't be a problem if we were using native state instead of host objects.
The following:
!!("put any name" in hostHobject) // Will always return true no matter what
@tmikov there is probably a semantic that I am missing here, if you could refresh me on what is the semantic here? Could this be a bug? I'm not sure.
Hi, unfortunately HostObject does not support the "in" operation, because the HostObject API doesn't allow it: it only has 'get(), set()andgetPropertyNames(). There is no has()` method.
This is unfortunately by design. See here: https://github.com/facebook/hermes/blob/05d9e75f80b9e402e9f45c2f7118a02f11283e2e/lib/VM/JSObject.cpp#L1277
Yes, HostObject is awful... (though this probably doesn't help you).
I am not sure what a solution here would look like. I am open to suggestions.
in our case always returning false instead of always returning true would be great :)
On Fri 23 Aug 2024 at 05:11, Tzvetan Mikov @.***> wrote:
Hi, unfortunately HostObject does not support the "in" operation, because the HostObject API doesn't allow it: it only has 'get(), set()and getPropertyNames(). There is no has()` method.
This is unfortunately by design. See here:
https://github.com/facebook/hermes/blob/05d9e75f80b9e402e9f45c2f7118a02f11283e2e/lib/VM/JSObject.cpp#L1277
Yes, HostObject is awful... (though this probably doesn't help you).
I am not sure what a solution here would look like. I am open to suggestions.
— Reply to this email directly, view it on GitHub https://github.com/facebook/hermes/issues/1490#issuecomment-2306100614 or unsubscribe https://github.com/notifications/unsubscribe-auth/AACKXVRFEN4QJNU5PQD3JFDZS2R7RBFKMF2HI4TJMJ2XIZLTSSBKK5TBNR2WLJDUOJ2WLJDOMFWWLO3UNBZGKYLEL5YGC4TUNFRWS4DBNZ2F6YLDORUXM2LUPGBKK5TBNR2WLJDUOJ2WLJDOMFWWLLTXMF2GG2C7MFRXI2LWNF2HTAVFOZQWY5LFUVUXG43VMWSG4YLNMWVXI2DSMVQWIX3UPFYGLAVFOZQWY5LFVIYTCMBQGQ2DCMZYGSSG4YLNMWUWQYLTL5WGCYTFNSWHG5LCNJSWG5C7OR4XAZNMJFZXG5LFINXW23LFNZ2KM5DPOBUWG44TQKSHI6LQMWVHEZLQN5ZWS5DPOJ42K5TBNR2WLKJRGU2DEMBRGI2TTAVEOR4XAZNFNFZXG5LFUV3GC3DVMWVDENBYGE2DGMRQHE3YFJDUPFYGLJLMMFRGK3FFOZQWY5LFVIYTCMBQGQ2DCMZYGSTXI4TJM5TWK4VGMNZGKYLUMU . You are receiving this email because you authored the thread.
Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub .
We can't change the current behavior because that would break the existing API contract. However we can do betterL we discussed it and decided to add a has() method to HostObject. Unfortunately, it will take some time for this to propagate to users.
Meanwhile I hope you can read the property and compare it to undefined to get a similar result.