Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Make Platform.enableBindingsReflection a property
Browse files Browse the repository at this point in the history
This way, non-NodeBind code can know whether to populate the .bindings_ object.

R=arv
BUG=

Review URL: https://codereview.appspot.com/77100044
  • Loading branch information
rafaelw committed Mar 17, 2014
1 parent 230d5b2 commit 66f8444
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 10 additions & 3 deletions src/NodeBind.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,16 @@

var maybeUpdateBindings = returnBinding;

Platform.enableBindingsReflection = function(enable) {
maybeUpdateBindings = enable? updateBindings : returnBinding;
};
Object.defineProperty(Platform, 'enableBindingsReflection', {
get: function() {
return maybeUpdateBindings === updateBindings;
},
set: function(enable) {
maybeUpdateBindings = enable ? updateBindings : returnBinding;
return enable;
},
configurable: true
});

Text.prototype.bind = function(name, value, oneTime) {
if (name !== 'textContent')
Expand Down
4 changes: 2 additions & 2 deletions tests/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,15 @@ suite('Element attribute bindings', function() {
test('Platform.enableBindingsReflection', function(done) {
var el = testDiv.appendChild(document.createElement('div'));
var model = {a: '1'};
Platform.enableBindingsReflection(true);
Platform.enableBindingsReflection = true;
bindings.push(el.bind('foo', new PathObserver(model, 'a')));
bindings.push(el.bind('bar', new PathObserver(model, 'a')));
bindings.push(el.bind('baz', new PathObserver(model, 'a')));

then(function() {
assert.deepEqual(['bar', 'baz', 'foo'],
Object.keys(el.bindings_).sort());
Platform.enableBindingsReflection(false);
Platform.enableBindingsReflection = false;
done();
});
});
Expand Down

0 comments on commit 66f8444

Please sign in to comment.