Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.
This repository was 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

Description

@dukehoops-zz

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions