Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

oldCollection always .equals(); never === to newCollection in $watchCollection #6041

Closed
dukehoops-zz opened this issue Jan 29, 2014 · 2 comments

Comments

@dukehoops-zz
Copy link
Contributor

Docs for $watchCollection 's listener say:

listener a callback function that is

  • fired with both the newCollection and oldCollection as parameters.
  • The newCollection object is the newly modified data obtained from the obj expression
  • and the oldCollection object is a copy of the former collection data.

In my demo (http://plnkr.co/edit/WXGn5LaoiJmLzJ8rMImQ?p=preview - open JS console) I see:

  1. (bug) oldCollection always .equals() newCollection - even when array is mutated or replaced altogether
  2. (perhaps design flaw) oldCollection !== newCollection on first invocation - unlike in $watch. IMO behavior should be consistent between the two methods and on first invocation oldCollection must be === newCollection - to be able to easily tell that it is - in fact - first invocation
@Narretz
Copy link
Contributor

Narretz commented Feb 1, 2014

duplicate of #2621
incomplete pull request in #5688

@pkozlowski-opensource
Copy link
Member

Thnx @Narretz, it is indeed a duplicate. Closing this one.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants