From ccaebf0100fd209102f3c68b5a413edefb19dd1f Mon Sep 17 00:00:00 2001 From: Kevin Ngo Date: Thu, 21 Jul 2016 21:23:49 -0700 Subject: [PATCH] add component/system name to prop warnings (#1649) --- src/core/component.js | 6 +++--- src/core/schema.js | 7 +++++-- src/core/system.js | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/core/component.js b/src/core/component.js index db5accb0043..9121713df85 100644 --- a/src/core/component.js +++ b/src/core/component.js @@ -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); }, /** @@ -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; diff --git a/src/core/schema.js b/src/core/schema.js index 66fdff1cb9b..d30c8c26a90 100644 --- a/src/core/schema.js +++ b/src/core/schema.js @@ -88,9 +88,11 @@ 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; } @@ -98,7 +100,8 @@ module.exports.parseProperties = function (propData, schema, getPartialData, sil // 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 + '`.'); } }); diff --git a/src/core/system.js b/src/core/system.js index 34522288f47..2b913c0e018 100755 --- a/src/core/system.js +++ b/src/core/system.js @@ -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 = {