I came across the following code in Polymer the other day:
// capture A's value if B's value is null or undefined,
// otherwise use B's value
function resolveBindingValue(oldValue, value) {
if (value === undefined && oldValue === null) {
return value;
}
return (value === null || value === undefined) ? oldValue : value;
}
https://github.com/Polymer/polymer-dev/blob/master/src/instance/properties.js#L167
The last line is what interests me. From where this is called in
bindProperty(), it means that if a model property being bound to is null,
it's set to the element property. Otherwise the flow is from model to
element by default, if the binding is not two way.
What's the reasoning behind this special initialization path? The behavior
is a bit surprising to me. When my model's property that I'm binding to is
null, I don't expect any special initialization behavior. Especially since
null might be a valid value for the model property. This also makes all
bindings potentially two way, even when you think you know that the element
property you're binding to doesn't ever update.
Thanks,
Justin
Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups
"Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/CAEKsHmD-%2BMHFL3J%2BbRJEcG3WG3eZz90TPbaqj1rRPkX94CD7%2BQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.