When two properties are bound together we must merge two sources-of-truth
into one, which entails inherent conflicts. The rule has always been that
if one of the two properties is _valued_ (not null or undefined), then it
becomes the new shared value, regardless of direction.

Recently we decided to also prevent transitions between undefined and null
from being reported as `*Changed`. It's true this is a lossy change, but it
prevents a lot of unwanted side-effects at construction time where various
properties tend to be in either state, but are almost always indicative of
an _uninitialized_ state.



On Mon, Jun 2, 2014 at 10:32 AM, 'Justin Fagnani' via Polymer <
[email protected]> wrote:

> 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
> <https://groups.google.com/d/msgid/polymer-dev/CAEKsHmD-%2BMHFL3J%2BbRJEcG3WG3eZz90TPbaqj1rRPkX94CD7%2BQ%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

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/CAHbmOLbs24TbS2qXVTpAF0%2BxPH%3D3mp-N1CHA2jPJP1mgGmCA2g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to