fix(di): removed default visibility
BREAKING CHANGE:
Directives will use the Unbounded visibility by default, whereas before the change they used Self
This commit is contained in:
@@ -40,7 +40,7 @@ import {
|
||||
Directive,
|
||||
onDestroy
|
||||
} from 'angular2/annotations';
|
||||
import {bind, Injector, Binding, Optional, Inject, Injectable, Self, Parent, Ancestor, Unbounded, self, InjectMetadata, ParentMetadata} from 'angular2/di';
|
||||
import {bind, Injector, Binding, Optional, Inject, Injectable, Self, Parent, Ancestor, Unbounded, InjectMetadata, ParentMetadata} from 'angular2/di';
|
||||
import {AppProtoView, AppView} from 'angular2/src/core/compiler/view';
|
||||
import {ViewContainerRef} from 'angular2/src/core/compiler/view_container_ref';
|
||||
import {ProtoViewRef} from 'angular2/src/core/compiler/view_ref';
|
||||
@@ -73,16 +73,16 @@ class DummyElementRef extends SpyObject {
|
||||
noSuchMethod(m) { return super.noSuchMethod(m); }
|
||||
}
|
||||
|
||||
@Injectable(self)
|
||||
@Injectable()
|
||||
class SimpleDirective {}
|
||||
|
||||
class SimpleService {}
|
||||
|
||||
@Injectable(self)
|
||||
@Injectable()
|
||||
class SomeOtherDirective {}
|
||||
|
||||
var _constructionCount = 0;
|
||||
@Injectable(self)
|
||||
@Injectable()
|
||||
class CountingDirective {
|
||||
count;
|
||||
constructor() {
|
||||
@@ -91,7 +91,7 @@ class CountingDirective {
|
||||
}
|
||||
}
|
||||
|
||||
@Injectable(self)
|
||||
@Injectable()
|
||||
class FancyCountingDirective extends CountingDirective {
|
||||
constructor() { super(); }
|
||||
}
|
||||
@@ -99,13 +99,13 @@ class FancyCountingDirective extends CountingDirective {
|
||||
@Injectable()
|
||||
class NeedsDirective {
|
||||
dependency: SimpleDirective;
|
||||
constructor(dependency: SimpleDirective) { this.dependency = dependency; }
|
||||
constructor(@Self() dependency: SimpleDirective) { this.dependency = dependency; }
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
class OptionallyNeedsDirective {
|
||||
dependency: SimpleDirective;
|
||||
constructor(@Optional() dependency: SimpleDirective) { this.dependency = dependency; }
|
||||
constructor(@Self() @Optional() dependency: SimpleDirective) { this.dependency = dependency; }
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
|
||||
@@ -16,9 +16,7 @@ import {
|
||||
forwardRef,
|
||||
DependencyMetadata,
|
||||
Injectable,
|
||||
InjectMetadata,
|
||||
self,
|
||||
unbounded
|
||||
InjectMetadata
|
||||
} from 'angular2/di';
|
||||
|
||||
import {InjectorInlineStrategy, InjectorDynamicStrategy} from 'angular2/src/di/injector';
|
||||
@@ -29,15 +27,6 @@ class CustomDependencyMetadata extends DependencyMetadata {}
|
||||
|
||||
class Engine {}
|
||||
|
||||
@Injectable(self)
|
||||
class EngineWithSetVisibility {
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
class CarNeedsEngineWithSetVisibility {
|
||||
constructor(engine: EngineWithSetVisibility) {}
|
||||
}
|
||||
|
||||
class BrokenEngine {
|
||||
constructor() { throw new BaseException("Broken Engine"); }
|
||||
}
|
||||
@@ -417,19 +406,5 @@ export function main() {
|
||||
expect(binding.dependencies[0].properties).toEqual([new CustomDependencyMetadata()]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("default visibility", () => {
|
||||
it("should use the provided visibility", () => {
|
||||
var bindings = Injector.resolve([CarNeedsEngineWithSetVisibility, EngineWithSetVisibility]);
|
||||
var carBinding = bindings[0];
|
||||
expect(carBinding.dependencies[0].visibility).toEqual(self);
|
||||
});
|
||||
|
||||
it("should set the default visibility to unbounded", () => {
|
||||
var bindings = Injector.resolve([Car, Engine]);
|
||||
var carBinding = bindings[0];
|
||||
expect(carBinding.dependencies[0].visibility).toEqual(unbounded);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user