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

Scope#$watchCollection oldValue == newValue fix #6736

Closed
wants to merge 2 commits into from

Commits on Mar 18, 2014

  1. chore(log): add log.empty() method to the testing logger

    `log.empty()` is the same as `log.reset()`, except thati `empty()`  also returns the current array with messages
    
    instead of:
    
    ```
    // do work
    expect(log).toEqual(['bar']);
    log.reset();
    ```
    
    do:
    
    ```
    // do work
    expect(log.empty()).toEqual(['bar']);
    ```
    IgorMinar committed Mar 18, 2014
    Configuration menu
    Copy the full SHA
    c5e41a0 View commit details
    Browse the repository at this point in the history
  2. fix(Scope): $watchCollection should call listener with oldValue

    Originally we destroyed the oldValue by incrementaly copying over portions of the newValue
    into the oldValue during dirty-checking, this resulted in oldValue to be equal to newValue
    by the time we called the watchCollection listener.
    
    The fix creates a copy of the newValue each time a change is detected and then uses that
    copy *the next time* a change is detected.
    
    To make `$watchCollection` behave the same way as `$watch`, during the first iteration
    the listener is called with newValue and oldValue being identical.
    
    Since many of the corner-cases are already covered by existing tests, I refactored the
    test logging to include oldValue and made the tests more readable.
    
    Closes angular#2621
    Closes angular#5661
    Closes angular#5688
    Closes angular#6736
    IgorMinar committed Mar 18, 2014
    Configuration menu
    Copy the full SHA
    78057a9 View commit details
    Browse the repository at this point in the history