Chromium Code Reviews
DescriptionAutomate 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
Committed: https://chromium.googlesource.com/external/mojo/+/a0235a16d45cfaca40274db73e84bcf6bd25c72d
Patch Set 1 #
Total comments: 8
Patch Set 2 : abarth review #Patch Set 3 : single quotes. #Patch Set 4 : moar single quotes #
Messages
Total messages: 10 (2 generated)
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||