Reflecting properties to attributes is now opt-in

231 views
Skip to first unread message

Steve Orvell

unread,
Apr 21, 2014, 2:02:02 PM4/21/14
to polym...@googlegroups.com
In the latest polymer release, we've made reflection of property values to attribute values opt-in. We've done this mainly as a performance optimization. Published properties maintain their other previous behaviors: they are bound as properties and corresponding attribute values are deserialized and set to property values. 

To cause a property to reflect to an attribute, use the publish block and set a property value that's an object literal with a value property specifying the property's default value and a reflect property with the value set to true. Here's an example:

publish: {
  // won't reflect to an attribute
  bigText: '',
  // will reflect to an attribute
  active: {value: false, reflect: true}
}

Here's some more information:

Typically it's important to reflect to attributes only properties that will be used for styling. Previously Polymer did this for all published properties, and this led to unnecessary work. Additionally, there are some properties that simply don't make sense to reflect to attributes. In the example above, if the bigText property was set to a 10k character string, we really would not want to reflect that to an attribute. This is why we've decided to make property reflection to attributes opt-in.

cletusw

unread,
May 24, 2014, 9:04:43 PM5/24/14
to polym...@googlegroups.com
The docs haven't been updated with regards to this yet, right? http://www.polymer-project.org/docs/polymer/polymer.html#attrreflection

Clayton

Eric Bidelman

unread,
May 24, 2014, 11:18:07 PM5/24/14
to cletusw, polym...@googlegroups.com

Not yet. Arthur is working on it.

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/ef382069-6488-4185-a4d7-5da01e7d90ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Clayton Watts

unread,
May 25, 2014, 12:10:59 AM5/25/14
to Eric Bidelman, polym...@googlegroups.com
Awesome, thanks!
Reply all
Reply to author
Forward
0 new messages