kiva / backbone.siren

Converts Siren JSON representations into Backbone Models
MIT License
14 stars 3 forks source link

ToJSON looses options when serializing multiple objects (recursing) #71

Open giblfiz opened 10 years ago

giblfiz commented 10 years ago

In Backbone.Siren.js Around line 912, where ToJSON is defined...

When this is called as part of a recursive structor, or on a collection, the "Options" that were passed to it only are maintained the first time it's called...

specifically the example I just encountered was: Calling it on a collection of team attributes: (several teams in the collection) The first option "actionName" started off set to "updateTeamCommunicationSettings". For the first team in the collection this setting was respected, and the list of fields was fetched for retrieval.

for every team object AFTER that the "actionName" became blank and all of fields were serialized.

the "actionName" should be retained, and field list should be enforced for each object.