Binding internal changes of custom element's attributes to outter scope

174 views
Skip to first unread message

tomal...@gmail.com

unread,
Jan 23, 2014, 11:57:32 AM1/23/14
to polym...@googlegroups.com
Hi,

I'm a bit confused what is the right way to do so, especially that my snippet behaves inconstantly between Canary and regular Chrome.


(I took from http://www.polymer-project.org/getting-started.html as a merge of  binding between elements and 'Publishing properties')

In regular Chrome (32.0.1700.76 m) it behaves as I desire - it binds all 4 {{name}} together. However, Canary (34.0.1799.0 canary) isolates changes to (published) attribute made within custom element.

Is it a bug in Canary? 
If not, what is the correct way to notify outer binding about attribute's change?

Thanks,

Marcin Warpechowski

unread,
Feb 25, 2014, 7:37:16 AM2/25/14
to polym...@googlegroups.com
Now the behaviour in the OP JSFiddle link is consistent in Canary (WP flag enabled) and Chrome stable (WP flag disabled) - changes made inside the Polymer Element are not propagated to the model. 

Is this intentional? What's the workaround?

Steve Orvell

unread,
Feb 25, 2014, 10:11:34 AM2/25/14
to Marcin Warpechowski, polym...@googlegroups.com
It's important to wait until the element's definition is ready before stamping the template. Elements defined with <polymer-element> are registered asynchronously, so the fix is to wrap the code in an event handler that waits for the 'polymer-ready' event. Here's an updated example:


More info: Node.bind allows elements to customize how they are bound. By default most elements bind to attributes and these bindings are 1-way. Polymer allows elements to expose published properties (those in the attributes attribute or publish block) which bind as properties and are two way. In order for this 2-way binding to be setup correctly, the element must be created with the proper definition so that it gets the right bind method implementation. If the element is bound when the definition is not available, then an attribute binding is created and it is 1-way.


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 polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/ca68447a-1609-4aab-8d23-54568f8707ad%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Tomek W

unread,
Feb 25, 2014, 1:10:30 PM2/25/14
to polym...@googlegroups.com, Marcin Warpechowski
Thanks a lot Steve, for easy solution, and full explanation :)
Reply all
Reply to author
Forward
0 new messages