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

Commit c6cc7f4

Browse files
committed
Enable opt-in attribute reflection via publish block.
e.g. publish: { foo: {value: 'bar', reflect: true} }
1 parent 1ca8375 commit c6cc7f4

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

src/declaration/properties.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@
9797
var n$ = prototype._publishNames;
9898
if (n$ && n$.length) {
9999
for (var i=0, l=n$.length, n, fn; (i<l) && (n=n$[i]); i++) {
100-
fn = prototype.reflect[n] ? prototype.reflectPropertyToAttribute :
101-
null;
102-
Observer.createBindablePrototypeAccessor(prototype, n, fn);
100+
Observer.createBindablePrototypeAccessor(prototype, n);
103101
}
104102
}
105103
}

src/instance/properties.js

+5
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@
5858
}
5959
}
6060
},
61+
propertyChanged_: function(name, value, oldValue) {
62+
if (this.reflect[name]) {
63+
this.reflectPropertyToAttribute(name);
64+
}
65+
},
6166
observeArrayValue: function(name, value, old) {
6267
// we only care if there are registered side-effects
6368
var callbackName = this.observe[name];

test/js/attrs.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,5 @@ htmlSuite('attributes-declarative', function() {
88
htmlTest('html/publish-attributes.html');
99
htmlTest('html/take-attributes.html');
1010
htmlTest('html/attr-mustache.html');
11-
// TODO(sorvell): replace test when observe.js is updated.
12-
//htmlTest('html/prop-attr-reflection.html');
11+
htmlTest('html/prop-attr-reflection.html');
1312
});

0 commit comments

Comments
 (0)