src/core/component.js
function (newData, clobber, silent) {
    var componentDefined;
    var data;
    var defaultValue;
    var key;
    var mixinData;
    var nextData = this.nextData;
    var schema = this.schema;
    var i;
    var mixinEls = this.el.mixinEls;
    var previousData;

    // Whether component has a defined value. For arrays, treat empty as not defined.
    componentDefined = newData && newData.constructor === Array
      ? newData.length
      : newData !== undefined && newData !== null;

    if (this.isObjectBased) { utils.objectPool.clearObject(nextData); }

    // 1. Gather default values (lowest precendence).
    if (this.isSingleProperty) {
      if (this.isObjectBased) {
        // If object-based single-prop, then copy over the data to our pooled object.
        data = copyData(nextData, schema.default);
      } else {
        // If is plain single-prop, copy by value the default.
        data = isObjectOrArray(schema.default)
          ? utils.clone(schema.default)
          : schema.default;
      }
    } else {
      // Preserve previously set properties if clobber not enabled.
      previousData = !clobber && this.attrValue;

      // Clone default value if object so components don't share object
      data = previousData instanceof Object
        ? copyData(nextData, previousData)
        : nextData;

      // Apply defaults.
      for (key in schema) {
        defaultValue = schema[key].default;
        if (data[key] !== undefined) { continue; }
        // Clone default value if object so components don't share object
        data[key] = isObjectOrArray(defaultValue)
          ? utils.clone(defaultValue)
          : defaultValue;
      }
    }

    // 2. Gather mixin values.
    for (i = 0; i < mixinEls.length; i++) {
      mixinData = mixinEls[i].getAttribute(this.attrName);
      if (!mixinData) { continue; }
      data = extendProperties(data, mixinData, this.isObjectBased);
    }

    // 3. Gather attribute values (highest precendence).
    if (componentDefined) {
      if (this.isSingleProperty) {
        // If object-based, copy the value to not modify the original.
        if (isObject(newData)) {
          copyData(this.parsingAttrValue, newData);
          return parseProperty(this.parsingAttrValue, schema);
        }
        return parseProperty(newData, schema);
      }
      data = extendProperties(data, newData, this.isObjectBased);
    } else {
      // Parse and coerce using the schema.
      if (this.isSingleProperty) { return parseProperty(data, schema); }
    }

    return parseProperties(data, schema, undefined, this.name, silent);
  }
function (newData, clobber, silent) {
    var componentDefined;
    var data;
    var defaultValue;
    var key;
    var mixinData;
    var nextData = this.nextData;
    var schema = this.schema;
    var i;
    var mixinEls = this.el.mixinEls;
    var previousData;

    // Whether component has a defined value. For arrays, treat empty as not defined.
    componentDefined = newData && newData.constructor === Array
      ? newData.length
      : newData !== undefined && newData !== null;

    if (this.isObjectBased) { utils.objectPool.clearObject(nextData); }

    // 1. Gather default values (lowest precendence).
    if (this.isSingleProperty) {
      if (this.isObjectBased) {
        // If object-based single-prop, then copy over the data to our pooled object.
        data = copyData(nextData, schema.default);
      } else {
        // If is plain single-prop, copy by value the default.
        data = isObjectOrArray(schema.default)
          ? utils.clone(schema.default)
          : schema.default;
      }
    } else {
      // Preserve previously set properties if clobber not enabled.
      previousData = !clobber && this.attrValue;

      // Clone default value if object so components don't share object
      data = previousData instanceof Object
        ? copyData(nextData, previousData)
        : nextData;

      // Apply defaults.
      for (key in schema) {
        defaultValue = schema[key].default;
        if (data[key] !== undefined) { continue; }
        // Clone default value if object so components don't share object
        data[key] = isObjectOrArray(defaultValue)
          ? utils.clone(defaultValue)
          : defaultValue;
      }
    }

    // 2. Gather mixin values.
    for (i = 0; i < mixinEls.length; i++) {
      mixinData = mixinEls[i].getAttribute(this.attrName);
      if (!mixinData) { continue; }
      data = extendProperties(data, mixinData, this.isObjectBased);
    }

    // 3. Gather attribute values (highest precendence).
    if (componentDefined) {
      if (this.isSingleProperty) {
        // If object-based, copy the value to not modify the original.
        if (isObject(newData)) {
          copyData(this.parsingAttrValue, newData);
          return parseProperty(this.parsingAttrValue, schema);
        }
        return parseProperty(newData, schema);
      }
      data = extendProperties(data, newData, this.isObjectBased);
    } else {
      // Parse and coerce using the schema.
      if (this.isSingleProperty) { return parseProperty(data, schema); }
    }

    return parseProperties(data, schema, undefined, this.name, silent);
  }
function ( newData , clobber , silent ) { var componentDefined ; var data ; var defaultValue ; var key ; var mixinData ; var nextData = this . nextData ; var schema = this . schema ; var i ; var mixinEls = this . el . mixinEls ; var previousData ; // Whether component has a defined value. For arrays, treat empty as not defined. componentDefined = newData && newData . constructor === Array ? newData . length : newData !== undefined && newData !== null ; if ( this . isObjectBased ) { utils . objectPool . clearObject ( nextData ) ; } // 1. Gather default values (lowest precendence). if ( this . isSingleProperty ) { if ( this . isObjectBased ) { // If object-based single-prop, then copy over the data to our pooled object. data = copyData ( nextData , schema . default ) ; } else { // If is plain single-prop, copy by value the default. data = isObjectOrArray ( schema . default ) ? utils . clone ( schema . default ) : schema . default ; } } else { // Preserve previously set properties if clobber not enabled. previousData = ! clobber && this . attrValue ; // Clone default value if object so components don't share object data = previousData instanceof Object ? copyData ( nextData , previousData ) : nextData ; // Apply defaults. for ( key in schema ) { defaultValue = schema [ key ] . default ; if ( data [ key ] !== undefined ) { continue ; } // Clone default value if object so components don't share object data [ key ] = isObjectOrArray ( defaultValue ) ? utils . clone ( defaultValue ) : defaultValue ; } } // 2. Gather mixin values. for ( i = 0 ; i < mixinEls . length ; i ++ ) { mixinData = mixinEls [ i ] . getAttribute ( this . attrName ) ; if ( ! mixinData ) { continue ; } data = extendProperties ( data , mixinData , this . isObjectBased ) ; } // 3. Gather attribute values (highest precendence). if ( componentDefined ) { if ( this . isSingleProperty ) { // If object-based, copy the value to not modify the original. if ( isObject ( newData ) ) { copyData ( this . parsingAttrValue , newData ) ; return parseProperty ( this . parsingAttrValue , schema ) ; } return parseProperty ( newData , schema ) ; } data = extendProperties ( data , newData , this . isObjectBased ) ; } else { // Parse and coerce using the schema. if ( this . isSingleProperty ) { return parseProperty ( data , schema ) ; } } return parseProperties ( data , schema , undefined , this . name , silent ) ; }
Build component data from the current state of the entity.data.

Precedence:
1. Defaults data
2. Mixin data.
3. Attribute data.

Finally coerce the data to the types of the defaults.

@param {object} newData - Element new data.
@param {boolean} clobber - The previous data is completely replaced by the new one.
@param {boolean} silent - Suppress warning messages.
@return {object} The component data
Build component data from the current state of the entity . data .