Skip to content

Commit

Permalink
add component/system name to prop warnings (aframevr#1649)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngokevin authored and dmarcos committed Jul 22, 2016
1 parent 1eda7a4 commit ccaebf0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/core/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ Component.prototype = {
parse: function (value, silent) {
var schema = this.schema;
if (isSingleProp(schema)) { return parseProperty(value, schema); }
return parseProperties(styleParser.parse(value), schema, true, silent);
return parseProperties(styleParser.parse(value), schema, true, this.name, silent);
},

/**
Expand Down Expand Up @@ -335,11 +335,11 @@ function buildData (el, name, schema, elData, silent) {
if (componentDefined) {
if (isSinglePropSchema) { return parseProperty(elData, schema); }
data = extendProperties(data, elData, isSinglePropSchema);
return parseProperties(data, schema, undefined, silent);
return parseProperties(data, schema, undefined, name, silent);
} else {
// Parse and coerce using the schema.
if (isSinglePropSchema) { return parseProperty(data, schema); }
return parseProperties(data, schema, undefined, silent);
return parseProperties(data, schema, undefined, name, silent);
}
}
module.exports.buildData = buildData;
Expand Down
7 changes: 5 additions & 2 deletions src/core/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ module.exports.processPropertyDefinition = processPropertyDefinition;
* @param {object} schema - Property types definition.
* @param {boolean} getPartialData - Whether to return full component data or just the data
* with keys in `propData`.
* @param {string } componentName - Name of the component, used for the property warning.
* @param {boolean} silent - Suppress warning messages.
*/
module.exports.parseProperties = function (propData, schema, getPartialData, silent) {
module.exports.parseProperties = function (propData, schema, getPartialData, componentName,
silent) {
var propNames = Object.keys(getPartialData ? propData : schema);

if (propData === null || typeof propData !== 'object') { return propData; }

// Validation errors.
Object.keys(propData).forEach(function (propName) {
if (!schema[propName] && !silent) {
warn('Unknown component property: ' + propName);
warn('Unknown property `' + propName +
'` for component/system `' + componentName + '`.');
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/core/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var System = module.exports.System = function (sceneEl) {
this.data = parseProperty(rawData, schema);
return;
}
this.data = parseProperties(styleParser.parse(rawData) || {}, schema);
this.data = parseProperties(styleParser.parse(rawData) || {}, schema, false, this.name);
};

System.prototype = {
Expand Down

0 comments on commit ccaebf0

Please sign in to comment.