@@ -12,10 +12,11 @@ import { PathUtils } from "../path/pathFactory";
12
12
import { stringify } from "../common/strings" ;
13
13
import { Transition } from "../transition/transition" ;
14
14
import { UIInjector } from "../interface" ;
15
+ import { isUndefined } from '../common' ;
15
16
16
- const when = resolvePolicies . when ;
17
- const ALL_WHENS = [ when . EAGER , when . LAZY ] ;
18
- const EAGER_WHENS = [ when . EAGER ] ;
17
+ const whens = resolvePolicies . when ;
18
+ const ALL_WHENS = [ whens . EAGER , whens . LAZY ] ;
19
+ const EAGER_WHENS = [ whens . EAGER ] ;
19
20
20
21
export const NATIVE_INJECTOR_TOKEN : string = "Native Injector" ;
21
22
@@ -105,7 +106,7 @@ export class ResolveContext {
105
106
let keys = newResolvables . map ( r => r . token ) ;
106
107
node . resolvables = node . resolvables . filter ( r => keys . indexOf ( r . token ) === - 1 ) . concat ( newResolvables ) ;
107
108
}
108
-
109
+
109
110
/**
110
111
* Returns a promise for an array of resolved path Element promises
111
112
*
@@ -119,7 +120,7 @@ export class ResolveContext {
119
120
// If the caller specified EAGER, only the EAGER Resolvables are fetched.
120
121
// if the caller specified LAZY, both EAGER and LAZY Resolvables are fetched.`
121
122
let matchedWhens = whenOption === resolvePolicies . when . EAGER ? EAGER_WHENS : ALL_WHENS ;
122
-
123
+
123
124
// get the subpath to the state argument, if provided
124
125
trace . traceResolvePath ( this . _path , when , trans ) ;
125
126
@@ -166,15 +167,15 @@ export class ResolveContext {
166
167
// subpath stopping at resolvable's node, or the whole path (if the resolvable isn't in the path)
167
168
let subPath : PathNode [ ] = PathUtils . subPath ( this . _path , x => x === node ) || this . _path ;
168
169
let availableResolvables : Resolvable [ ] = subPath
169
- . reduce ( ( acc , node ) => acc . concat ( node . resolvables ) , [ ] ) //all of subpath's resolvables
170
+ . reduce ( ( acc , _node ) => acc . concat ( _node . resolvables ) , [ ] ) //all of subpath's resolvables
170
171
. filter ( res => res !== resolvable ) ; // filter out the `resolvable` argument
171
172
172
173
const getDependency = ( token : any ) => {
173
174
let matching = availableResolvables . filter ( r => r . token === token ) ;
174
175
if ( matching . length ) return tail ( matching ) ;
175
176
176
177
let fromInjector = this . injector ( ) . getNative ( token ) ;
177
- if ( ! fromInjector ) {
178
+ if ( isUndefined ( fromInjector ) ) {
178
179
throw new Error ( "Could not find Dependency Injection token: " + stringify ( token ) ) ;
179
180
}
180
181
@@ -204,7 +205,8 @@ class UIInjectorImpl implements UIInjector {
204
205
}
205
206
return resolvable . data ;
206
207
}
207
- return this . native && this . native . get ( token ) ;
208
+
209
+ return this . getNative ( token ) ;
208
210
}
209
211
210
212
getAsync ( token : any ) {
@@ -216,4 +218,4 @@ class UIInjectorImpl implements UIInjector {
216
218
getNative ( token : any ) {
217
219
return this . native && this . native . get ( token ) ;
218
220
}
219
- }
221
+ }
0 commit comments