Elliott Sprehn 6d61fe6ce8 Automate reflected properties in SkyElement.
Now you can use the attributes attribute on <sky-element> that
accepts a set of name:type comma separated pairs to control
the reflected attributes. ex. attributes="size:number"

Each attribute creates a getter and a setter on the element that returns
the correct type and will coerce the string attribute values into the
right type. It also correctly hooks into the data binding system.

A new callback is added: {name}Changed(oldValue, newValue) which will
be invoked whenever the attribute with that name changes and gets the
correctly coerced type values. See the <sky-radio> or <sky-checkbox>
widgets for examples of using the new callback.

Number attributes default to 0, booleans to false, and strings to empty
string. There is no way provided to set a different default, for that you
can use hasAttribute in the created callback to conditionally set a value.
Don't just assign the property there otherwise you'll overwrite the value
from the parser.

Another behavior change from making this work is that now attributeChanged()
is called for each attribute, even when the element is created by the
parser.

Overall this allows a nice simplification to the <sky-button>,
<sky-radio> and <sky-checkbox> widgets.

R=abarth@chromium.org

Review URL: https://codereview.chromium.org/836923002
2015-01-05 20:12:58 -08:00
..
2015-01-02 19:56:45 -08:00
2014-11-11 13:52:50 -08:00