Skip to content

Instantly share code, notes, and snippets.

@frekw
Created September 18, 2010 21:32
Show Gist options
  • Save frekw/586055 to your computer and use it in GitHub Desktop.
Save frekw/586055 to your computer and use it in GitHub Desktop.
module("SC.TreeController - binding_bug", {});
test("observing a bound property in a treecontroller and using it to set its own 'content' property shouldn't cause an infinite loop", function(){
NameSpace = {};
NameSpace.a = SC.ArrayController.create({});
NameSpace.b = SC.TreeController.create({
counter: 0,
bar: null,
barBinding: 'NameSpace.a.content',
content: null,
test: function(){
var value = this.get('counter');
var bar = this.get('bar');
value++;
this.set('counter', value);
this.set('content', bar); // this is what causes the failure.
}.observes('bar')
});
NameSpace.a.set('content', [1, 2]);
SC.Binding.flushPendingChanges();
equals(1, NameSpace.b.get('counter'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment