Closed sandydoo closed 8 months ago
I found out that this behavior is mentioned in the docs.
Note that the hash is an empty object with no prototype chain, therefore common methods like toString are not available in the resulting hash. If you need to use such a method, you can use the call or apply approach:
I guess the solution here is to introduce a custom hash helper.
Description
The object created by the
hash
helper does not inherit fromObject.prototype
and is missing a lot of common functions likehasOwnProperty
.I've been a bit out of the loop, but it seems the behaviour may have changed in: https://github.com/glimmerjs/glimmer-vm/commit/52f5257c6013c6dde92790618328238ed589ee1d
Reproduce
The issue can be reproduced in the production docs for ember-google-maps: https://ember-google-maps.sandydoo.me/docs/directions
Throughout the docs for ember-google-maps, I suggest that people use the
hash
helper to quickly build up map settings without leaving the template. For example:The above currently breaks Google Maps when it tries to call
hasOwnProperty
on thepolylineOptions
object.Expected behaviour and feedback
Is this a reasonable use-case for the
hash
helper? Or should I ditch the idea and remove this pattern from the documentation?One could argue that creating the object outside of the template is the safer option, given how restrictive the hash helper is around updates. There's nothing stopping a third-party library like Google Maps from calling
set
in the future and breaking the app.It's also fair to argue that Google Maps should be using something like
Object.prototype.hasOwnProperty.call
to be safe.Any guidance, thoughts, and suggestions are very welcome!