Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncer calls onChangeHandler with wrong arguments with existing data #44

Closed
nilclass opened this issue Jun 5, 2012 · 1 comment
Closed

Comments

@nilclass
Copy link
Member

nilclass commented Jun 5, 2012

In line 420+, syncer/include.js calls the onChangeHandler for all items in all collections.
It gets called with wrong arguments:

  • "key" is the index in the array of items instead of the actual key
  • "newValue" is null, as getItem is called with the invalid key as well.

This is due to getCollection, which doesn't return any keys. Michiel mentioned in the channel, that in the original usecase this wasn't needed, as the items had their key duplicated as an "id" attribute. Depending on this may or may not be a good idea.
Either way, the bug described above is still a bug.

@nilclass
Copy link
Member Author

nilclass commented Jun 5, 2012

I solved this in 4cdab2c, by allowing getCollection to be called in two ways.

This is how it was (and still works):

syncer.getCollection('contacts') //=> [{...}, {...}, {...}, ...]

This is the new way:

syncer.getCollection('contacts', function(contact, key) {
   // ...
}); //=> null

@nilclass nilclass closed this as completed Jun 5, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant