feat(change_detection): pass binding propagation config to pipe registry
This commit is contained in:
@@ -535,6 +535,18 @@ export function main() {
|
||||
|
||||
expect(pipe.destroyCalled).toEqual(true);
|
||||
});
|
||||
|
||||
it("should inject the binding propagation configuration " +
|
||||
"of the encompassing component into a pipe", () => {
|
||||
|
||||
var registry = new FakePipeRegistry('pipe', () => new IdentityPipe());
|
||||
var c = createChangeDetector("memo", "name | pipe", new Person('bob'), null, registry);
|
||||
var cd = c["changeDetector"];
|
||||
|
||||
cd.detectChanges();
|
||||
|
||||
expect(registry.bpc).toBe(cd.bindingPropagationConfig);
|
||||
});
|
||||
});
|
||||
|
||||
it("should do nothing when returns NO_CHANGE", () => {
|
||||
@@ -622,6 +634,7 @@ class FakePipeRegistry extends PipeRegistry {
|
||||
numberOfLookups:number;
|
||||
pipeType:string;
|
||||
factory:Function;
|
||||
bpc:any;
|
||||
|
||||
constructor(pipeType, factory) {
|
||||
super({});
|
||||
@@ -630,9 +643,10 @@ class FakePipeRegistry extends PipeRegistry {
|
||||
this.numberOfLookups = 0;
|
||||
}
|
||||
|
||||
get(type:string, obj) {
|
||||
get(type:string, obj, bpc) {
|
||||
if (type != this.pipeType) return null;
|
||||
this.numberOfLookups ++;
|
||||
this.bpc = bpc;
|
||||
return this.factory();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,12 +16,12 @@ export function main() {
|
||||
]
|
||||
});
|
||||
|
||||
expect(r.get("type", "some object")).toBe(secondPipe);
|
||||
expect(r.get("type", "some object", null)).toBe(secondPipe);
|
||||
});
|
||||
|
||||
it("should throw when no matching type", () => {
|
||||
var r = new PipeRegistry({});
|
||||
expect(() => r.get("unknown", "some object")).toThrowError(
|
||||
expect(() => r.get("unknown", "some object", null)).toThrowError(
|
||||
`Cannot find a pipe for type 'unknown' object 'some object'`
|
||||
);
|
||||
});
|
||||
@@ -31,7 +31,7 @@ export function main() {
|
||||
"type" : []
|
||||
});
|
||||
|
||||
expect(() => r.get("type", "some object")).toThrowError(
|
||||
expect(() => r.get("type", "some object", null)).toThrowError(
|
||||
`Cannot find a pipe for type 'type' object 'some object'`
|
||||
);
|
||||
});
|
||||
@@ -51,7 +51,7 @@ class PipeFactory {
|
||||
return this.shouldSupport;
|
||||
}
|
||||
|
||||
create():Pipe {
|
||||
create(bpc):Pipe {
|
||||
return this.pipe;
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
import {NgElement} from 'angular2/src/core/dom/element';
|
||||
import {LightDom, DestinationLightDom} from 'angular2/src/core/compiler/shadow_dom_emulation/light_dom';
|
||||
import {Directive} from 'angular2/src/core/annotations/annotations';
|
||||
import {BindingPropagationConfig} from 'angular2/src/core/compiler/binding_propagation_config';
|
||||
import {BindingPropagationConfig} from 'angular2/change_detection';
|
||||
|
||||
@proxy
|
||||
@IMPLEMENTS(View)
|
||||
|
||||
+2
-3
@@ -18,7 +18,7 @@ import {PromiseWrapper} from 'angular2/src/facade/async';
|
||||
|
||||
import {Injector, bind} from 'angular2/di';
|
||||
import {Lexer, Parser, dynamicChangeDetection,
|
||||
DynamicChangeDetection, Pipe, PipeRegistry} from 'angular2/change_detection';
|
||||
DynamicChangeDetection, Pipe, PipeRegistry, BindingPropagationConfig} from 'angular2/change_detection';
|
||||
|
||||
import {Compiler, CompilerCache} from 'angular2/src/core/compiler/compiler';
|
||||
import {DirectiveMetadataReader} from 'angular2/src/core/compiler/directive_metadata_reader';
|
||||
@@ -27,7 +27,6 @@ import {PrivateComponentLocation} from 'angular2/src/core/compiler/private_compo
|
||||
import {PrivateComponentLoader} from 'angular2/src/core/compiler/private_component_loader';
|
||||
import {TemplateLoader} from 'angular2/src/core/compiler/template_loader';
|
||||
import {MockTemplateResolver} from 'angular2/src/mock/template_resolver_mock';
|
||||
import {BindingPropagationConfig} from 'angular2/src/core/compiler/binding_propagation_config';
|
||||
import {ComponentUrlMapper} from 'angular2/src/core/compiler/component_url_mapper';
|
||||
import {UrlResolver} from 'angular2/src/core/compiler/url_resolver';
|
||||
import {StyleUrlResolver} from 'angular2/src/core/compiler/style_url_resolver';
|
||||
@@ -869,7 +868,7 @@ class DoublePipeFactory {
|
||||
return true;
|
||||
}
|
||||
|
||||
create() {
|
||||
create(bpc) {
|
||||
return new DoublePipe();
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -660,7 +660,7 @@ class DoublePipeFactory {
|
||||
return true;
|
||||
}
|
||||
|
||||
create() {
|
||||
create(bpc) {
|
||||
return new DoublePipe();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user