canjs / can-connect

Model layer utilities for every JavaScript framework! Assemble real-time, high performance, restful data connections.
https://canjs.com/doc/can-connect.html
MIT License
29 stars 16 forks source link

check if props exist before running connection.id #516

Closed morganheimbeck closed 2 years ago

morganheimbeck commented 2 years ago

Test demonstrates the issue. connection.id requires props to be an object, otherwise it will throw. This is correct behavior, however it is not correct for hydrate to assume new DefineMap will have a property passed to it. DefineMap does not require a property to be passed, so hydrate should make a check before making any calls to functions that require props.

bmomberger-bitovi commented 2 years ago

I went one step beyond and used can-reflect.isMapLike to ensure that the props was an object that an id could potentially be extracted from (this excludes nullish values and primitives).