method attributeToProperty


void attributeToProperty(String name, String value)

If attribute name is mapped to a property, deserialize value into that property.

Source

void attributeToProperty(String name, String value) {
  // try to match this attribute to a property (attributes are
  // all lower-case, so this is case-insensitive search)
  var decl = propertyForAttribute(name);
  if (decl == null) return;

  // filter out 'mustached' values, these are to be
  // replaced with bound-data and are not yet values
  // themselves.
  if (value == null || value.contains(Polymer.bindPattern)) return;

  final currentValue = smoke.read(this, decl.name);

  // deserialize Boolean or Number values from attribute
  var type = decl.type;
  if ((type == Object || type == dynamic) && currentValue != null) {
    // Attempt to infer field type from the current value.
    type = currentValue.runtimeType;
  }
  final newValue = deserializeValue(value, currentValue, type);

  // only act if the value has changed
  if (!identical(newValue, currentValue)) {
    // install new value (has side-effects)
    smoke.write(this, decl.name, newValue);
  }
}