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

Commit

Permalink
Enable opt-in attribute reflection via publish block.
Browse files Browse the repository at this point in the history
e.g.

publish: {
  foo: {value: 'bar', reflect: true}
}
  • Loading branch information
sorvell committed Apr 17, 2014
1 parent 1ca8375 commit c6cc7f4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
4 changes: 1 addition & 3 deletions src/declaration/properties.js
Expand Up @@ -97,9 +97,7 @@
var n$ = prototype._publishNames;
if (n$ && n$.length) {
for (var i=0, l=n$.length, n, fn; (i<l) && (n=n$[i]); i++) {
fn = prototype.reflect[n] ? prototype.reflectPropertyToAttribute :
null;
Observer.createBindablePrototypeAccessor(prototype, n, fn);
Observer.createBindablePrototypeAccessor(prototype, n);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions src/instance/properties.js
Expand Up @@ -58,6 +58,11 @@
}
}
},
propertyChanged_: function(name, value, oldValue) {
if (this.reflect[name]) {
this.reflectPropertyToAttribute(name);
}
},
observeArrayValue: function(name, value, old) {
// we only care if there are registered side-effects
var callbackName = this.observe[name];
Expand Down
3 changes: 1 addition & 2 deletions test/js/attrs.js
Expand Up @@ -8,6 +8,5 @@ htmlSuite('attributes-declarative', function() {
htmlTest('html/publish-attributes.html');
htmlTest('html/take-attributes.html');
htmlTest('html/attr-mustache.html');
// TODO(sorvell): replace test when observe.js is updated.
//htmlTest('html/prop-attr-reflection.html');
htmlTest('html/prop-attr-reflection.html');
});

0 comments on commit c6cc7f4

Please sign in to comment.