This repository was archived by the owner on Sep 11, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Expand file tree Collapse file tree 1 file changed +16
-10
lines changed Original file line number Diff line number Diff line change @@ -23,22 +23,28 @@ class Skinner {
23
23
if ( this . components === null ) {
24
24
throw new Error (
25
25
"Attempted to get a component before a skin has been loaded." +
26
- "This is probably because either:" +
26
+ " This is probably because either:" +
27
27
" a) Your app has not called sdk.loadSkin(), or" +
28
- " b) A component has called getComponent at the root level"
28
+ " b) A component has called getComponent at the root level" ,
29
29
) ;
30
30
}
31
- var comp = this . components [ name ] ;
32
- if ( comp ) {
33
- return comp ;
34
- }
31
+ let comp = this . components [ name ] ;
35
32
// XXX: Temporarily also try 'views.' as we're currently
36
33
// leaving the 'views.' off views.
37
- var comp = this . components [ 'views.' + name ] ;
38
- if ( comp ) {
39
- return comp ;
34
+ if ( ! comp ) {
35
+ comp = this . components [ 'views.' + name ] ;
36
+ }
37
+
38
+ if ( ! comp ) {
39
+ throw new Error ( "No such component: " + name ) ;
40
+ }
41
+
42
+ // components have to be functions.
43
+ const validType = typeof comp === 'function' ;
44
+ if ( ! validType ) {
45
+ throw new Error ( `Not a valid component: ${ name } .` ) ;
40
46
}
41
- throw new Error ( "No such component: " + name ) ;
47
+ return comp ;
42
48
}
43
49
44
50
load ( skinObject ) {
You can’t perform that action at this time.
0 commit comments