Closed vicb closed 10 years ago
The root cause of the issue in angular is in the element binder:
probe = _expando[node] = new ElementProbe(
parentInjector.get(ElementProbe), node, nodeInjector, scope);
The first arg of the ElementProbe
ctor is the parent (ie an ElementProbe
) this causes the infinite recursion.
There must be something wrong in getting the parent injector in the newest DI ?
The problem seems to be with Angular Internal Module registers ElementProb
as null
value. And by DI code logic instead of registering it as a Value dependency, it is registered as Type.
if (toValue != null) {
_providers[key.id] = new ValueProvider(key.type, toValue, visibility);
} else if (toFactory != null) {
_providers[key.id] = new FactoryProvider(key.type, toFactory, visibility);
} else {
_providers[key.id] = new TypeProvider(
toImplementation == null ? key.type : toImplementation, visibility);
}
This results in this infinite search for the parent. Whereas the intention was that at root level Angular will supply fixed null
value as ElementProbe
so that when first ElementProbe
is created it is created with null
parent.
@neermitt :+1: you've found the root cause.
Could you please submit a PR to fix that ? (toValue
arg should have a default value set to _EMPTY_VALUE = whatever const object
and you should test for this value rather than testing for null).
It would be great to also add a unit test for that. Thanks.
PR with a fix #95
di version 0.0.40
pushed to pub
see https://github.com/angular/angular.dart/issues/961
The problem seems to be in
dynamic_injector.newInstanceOf()
which has an infinite recursion in some cases.