Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #137 from enyo-surya/master

Fix checks in enyo.kind for mistakenly undefined base kinds and throw an error if the kind property exists and is explicitly set to a misspelt value or if it evaluates to undefined at run-time. 

Reviewed-By: Ben Combee (ben.combee@palm.com)
Enyo-DCO-1.0-Signed-off-by: Surya Vakkalanka surya.vakkalanka@palm.com
  • Loading branch information...
commit 0779a393aefb48cad9e9d8f6fc72873e0d670b74 2 parents e208965 + a669e85
@unwiredben unwiredben authored
View
5 source/kernel/Component.js
@@ -230,6 +230,9 @@ enyo.kind({
inProps.owner = inProps.owner || this;
},
_createComponent: function(inInfo, inMoreInfo) {
+ if (!inInfo.kind && ("kind" in inInfo)) {
+ throw "enyo.create: Attempt to create a null kind. Check dependencies for [" + inInfo.name + "].";
+ }
// CAVEAT: inInfo and inMoreInfo are copied before mutation, but it's only a shallow copy
var props = enyo.mixin(enyo.clone(inMoreInfo), inInfo);
this.adjustComponentProps(props);
@@ -442,7 +445,7 @@ enyo.defaultCtor = enyo.Component;
enyo.create = enyo.Component.create = function(inConfig) {
if (!inConfig.kind && ("kind" in inConfig)) {
- throw "enyo.create: Attempt to create a null kind. Check dependencies.";
+ throw "enyo.create: Attempt to create a null kind. Check dependencies for [" + (inConfig.name || "") + "].";
}
var kind = inConfig.kind || inConfig.isa || enyo.defaultCtor;
var ctor = enyo.constructorForKind(kind);
View
28 tools/test/core/tests/ComponentTest.js
@@ -0,0 +1,28 @@
+enyo.kind({
+ name: "ComponentTest",
+ kind: enyo.TestSuite,
+ testNestedComponentUndefinedKind: function() {
+ var pass = false;
+ // should throw exception as this is an error
+ try {
+ var a = enyo.kind(
+ {
+ name: "parentComponent",
+ components: [
+ {
+ name: "nestedComponent",
+ kind: undefined
+ }
+ ]
+ }
+ );
+ new a({});
+ } catch(e) {
+ pass = true;
+ }
+ if (!pass) {
+ throw("no exception for explicitly undefined kind in a nested component");
+ }
+ this.finish();
+ }
+});
View
1  tools/test/core/tests/package.js
@@ -4,6 +4,7 @@ enyo.depends(
"JsonTest.js",
"AsyncTest.js",
"AjaxTest.js",
+ "ComponentTest.js",
"ComponentDispatchTest.js",
"ComponentHandlersTest.js",
"ControlPropsTest.js",
Please sign in to comment.
Something went wrong with that request. Please try again.