Closed sorvell closed 10 years ago
Ok. I see the issue. You've found a very subtle bug that only affects Object.observe-mode and depends on exactly the timing you stumbled on. The bug is in the optimization that I put in to minimize calls to Object.observe.
I'm still pondering what the best fix is. The test case that will go with the fix is:
test('issue-161', function(done) {
var model = {};
var ob1 = new PathObserver(model, 'obj.bar');
var called = false
ob1.open(function() {
called = true;
});
var obj2 = new PathObserver(model, 'obj');
obj2.open(function() {
model.obj.bar = true;
});
model.obj = {};
model.obj.foo = true;
then(function() {
assert.strictEqual(called, true);
done();
});
});
There appears to be a timing issue when data changes at a particular time. It's rather complicated but I boiled the issue down to this gist:
https://gist.github.com/sorvell/9243430
In the example, I expect that assert(obj.bar === true) will have true next to it. It does not.