Polymer: <child value="{{foo.bar}}"> always blows away child's value, even if undefined

Created on 16 May 2015  路  9Comments  路  Source: Polymer/polymer

<dom-module id='view'>
   <child value="{{foo.bar}}">
<dom-module>

This will always set child.value, even if view.foo.bar === undefined

When binding to structured data, parent always propagates binding to child, even if the property is undefined.

repro:
http://output.jsbin.com/xeweza/2/edit?html,output

This is different from simple property binding. Simple property binding will not propagate value unless defined.

This makes a common pattern impossible with structured properties:

  • parent has a value 'foo'
  • child should initialize value foo, so parent leaves foo undefined, and lets child initialize it with binding propagation.
  • parent's writes to foo propagate to child via binding

This works with foo, but not foo.bar

It kills you when trying to use iron-localstorage with structured variables. It'll probably kill any other data-access-layer too.

1.x databinding p2

Most helpful comment

Is there a plan for this ?

All 9 comments

To consider: do not propagate undefined for 2-way bindings in _distributeConfig

/sub

Was this ever fixed?

Can a placeholder that holds last valid inputs--provided faux validates are added to bindValue subProperties--act as a shim, shady, shadow, truth, or model data set for each individual object? And if so, is there an easy, native way to make the placeholder on the input act as a native data input. It has been an eon since I coded in a new language, or had anymore input on a code team than on the business side, that said, in the 90s, I recall a placeholder in HTML acting as a default input. I may be misremembering, but I am relatively certain there was an attribute at one point or another that served this function in native 1.0 HTML inputs.

If so, would such a placeholder solve this problem?

Something like this, plus a bind to the current object keys and values so that the "Mickey" in the below example would be 'bound' to itself in the input via a 'circular' bind.

object value-->defaultValue-->submittedInputValue--objectValue onNullSubmit

Like below, plus the 'circular bind'

http://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_text_defaultvalue3

Is there a plan for this ?

This qualifies as something bordering on crucial. Is there an action plan on this? Does anyone know what the heck is causing it? It's almost like a booby trap.

It seems that the original JSBin has been overwritten later. Is this still an issue in Polymer 2?

I am unable to reproduce this issue with Polymer 2 (http://jsbin.com/lunecugume/edit?html,console,output), thus I am closing it.

Was this page helpful?
0 / 5 - 0 ratings