Now that Object.observe()
is on by default in Chrome, I'm running into a bunch of cases where I want to reuse the browser's built in property (hidden
, title
, draggable
), but *Changed
watchers no longer get called when the property changes.
One example is hidden
: http://jsbin.com/jizikaje/1/edit (hiddenChanged()
is never called)
My current workaround is to use attributeChanged()
to observe the attribute changing:
attributeChanged: function(attrName, oldVal, newVal) {
// Cannot use *Changed watchers for these native properties.
if (attrName == 'hidden') {
this.marker.setVisible(!this.hidden);
}
}
What is the recommended approach?
BTW, throwing a warning when trying to use native properties will go a long for debugging: https://github.com/Polymer/polymer/issues/379
alert()
seems to be happening for me in Chrome 34. Maybe this has been fixed? – VotyakattributeChangedCallback
for free :) Either way, the solution is hacky. It relies on the fact that the native IDL properties also expose an attribute of the same name. So you're not observing the property, but attribute changing. – Hainaut