Polymer/observe-js — pull request #73 by jmesserly (2014-09-25 05:02:31+00:00)
Title: fix bug with rootObj optimization in observed sets

while investigating https://github.com/Polymer/polymer-dev/issues/101, I found two bugs with the rootObj optimization in observed sets:

* Models can have cycles, therefore, we may encounter the "root object" further down the path but not remember this fact. This leads to incorrectly failing to fire a change notification.

* At first, my new test only failed when run by itself, but passed in the full suite. This is because of a second bug: lastObservedSet can sometimes be the entry we just closed. This leads to confusion about whether the observer was closed or not, ultimately leaving it pointing at the wrong rootObject. I tried to mitigate this in two ways: instead of this.object and rootObj both tracking the same value, this is now handled explicitly in a setter to ensure they stay in sync. Also, if we close an observer make sure it is not still listed as the (alive) lastObservedSet.