refactor(pipes): rename PipeRegistry to Pipes
BREAKING CHANGE: This change renames all instances of PipeRegistry to Pipes. As part of this change, the former "defaultPipes" export is now a Pipes instance, instead of a map. The map that was previously called "defaultPipes" no longer exists, but may be accessed via defaultPipes.config.
This commit is contained in:
parent
8b3efdf229
commit
9a70f84e60
|
@ -14,14 +14,13 @@ export {
|
|||
|
||||
ChangeDetectorRef,
|
||||
|
||||
PipeRegistry,
|
||||
Pipes,
|
||||
WrappedValue,
|
||||
Pipe,
|
||||
PipeFactory,
|
||||
NullPipe,
|
||||
NullPipeFactory,
|
||||
defaultPipes,
|
||||
defaultPipeRegistry,
|
||||
BasePipe,
|
||||
|
||||
Locals
|
||||
|
|
|
@ -43,7 +43,7 @@ export {BindingRecord} from './src/change_detection/binding_record';
|
|||
export {DirectiveIndex, DirectiveRecord} from './src/change_detection/directive_record';
|
||||
export {DynamicChangeDetector} from './src/change_detection/dynamic_change_detector';
|
||||
export {ChangeDetectorRef} from './src/change_detection/change_detector_ref';
|
||||
export {PipeRegistry} from './src/change_detection/pipes/pipes';
|
||||
export {Pipes} from './src/change_detection/pipes/pipes';
|
||||
export {uninitialized} from './src/change_detection/change_detection_util';
|
||||
export {WrappedValue, Pipe, PipeFactory, BasePipe} from './src/change_detection/pipes/pipe';
|
||||
export {NullPipe, NullPipeFactory} from './src/change_detection/pipes/null_pipe';
|
||||
|
@ -52,6 +52,5 @@ export {
|
|||
DynamicChangeDetection,
|
||||
JitChangeDetection,
|
||||
PreGeneratedChangeDetection,
|
||||
preGeneratedProtoDetectors,
|
||||
defaultPipeRegistry
|
||||
preGeneratedProtoDetectors
|
||||
} from './src/change_detection/change_detection';
|
||||
|
|
|
@ -2,7 +2,7 @@ import {JitProtoChangeDetector} from './jit_proto_change_detector';
|
|||
import {PregenProtoChangeDetector} from './pregen_proto_change_detector';
|
||||
import {DynamicProtoChangeDetector} from './proto_change_detector';
|
||||
import {PipeFactory, Pipe} from './pipes/pipe';
|
||||
import {PipeRegistry} from './pipes/pipes';
|
||||
import {Pipes} from './pipes/pipes';
|
||||
import {IterableChangesFactory} from './pipes/iterable_changes';
|
||||
import {KeyValueChangesFactory} from './pipes/keyvalue_changes';
|
||||
import {ObservablePipeFactory} from './pipes/observable_pipe';
|
||||
|
@ -111,7 +111,7 @@ export const date: List<PipeFactory> =
|
|||
CONST_EXPR([CONST_EXPR(new DatePipe()), CONST_EXPR(new NullPipeFactory())]);
|
||||
|
||||
|
||||
export const defaultPipes = CONST_EXPR({
|
||||
export const defaultPipes: Pipes = CONST_EXPR(new Pipes({
|
||||
"iterableDiff": iterableDiff,
|
||||
"keyValDiff": keyValDiff,
|
||||
"async": async,
|
||||
|
@ -123,11 +123,11 @@ export const defaultPipes = CONST_EXPR({
|
|||
"percent": percent,
|
||||
"currency": currency,
|
||||
"date": date
|
||||
});
|
||||
}));
|
||||
|
||||
/**
|
||||
* Map from {@link ChangeDetectorDefinition#id} to a factory method which takes a
|
||||
* {@link PipeRegistry} and a {@link ChangeDetectorDefinition} and generates a
|
||||
* {@link Pipes} and a {@link ChangeDetectorDefinition} and generates a
|
||||
* {@link ProtoChangeDetector} associated with the definition.
|
||||
*/
|
||||
// TODO(kegluneq): Use PregenProtoChangeDetectorFactory rather than Function once possible in
|
||||
|
@ -198,5 +198,3 @@ export class JitChangeDetection extends ChangeDetection {
|
|||
return new JitProtoChangeDetector(definition);
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultPipeRegistry: PipeRegistry = CONST_EXPR(new PipeRegistry(defaultPipes));
|
||||
|
|
|
@ -20,7 +20,7 @@ import {ProtoRecord, RecordType} from './proto_record';
|
|||
var ABSTRACT_CHANGE_DETECTOR = "AbstractChangeDetector";
|
||||
var UTIL = "ChangeDetectionUtil";
|
||||
var DISPATCHER_ACCESSOR = "this.dispatcher";
|
||||
var PIPE_REGISTRY_ACCESSOR = "this.pipeRegistry";
|
||||
var PIPES_ACCESSOR = "this.pipes";
|
||||
var PROTOS_ACCESSOR = "this.protos";
|
||||
var DIRECTIVES_ACCESSOR = "this.directiveRecords";
|
||||
var CONTEXT_ACCESSOR = "this.context";
|
||||
|
@ -74,7 +74,7 @@ export class ChangeDetectorJITGenerator {
|
|||
${DIRECTIVES_ACCESSOR} = directiveRecords;
|
||||
${LOCALS_ACCESSOR} = null;
|
||||
${CURRENT_PROTO} = null;
|
||||
${PIPE_REGISTRY_ACCESSOR} = null;
|
||||
${PIPES_ACCESSOR} = null;
|
||||
${ALREADY_CHECKED_ACCESSOR} = false;
|
||||
${this._genFieldDefinitions()}
|
||||
}
|
||||
|
@ -111,13 +111,13 @@ export class ChangeDetectorJITGenerator {
|
|||
${this._genCallOnAllChangesDoneBody()}
|
||||
}
|
||||
|
||||
${typeName}.prototype.hydrate = function(context, locals, directives, pipeRegistry) {
|
||||
${typeName}.prototype.hydrate = function(context, locals, directives, pipes) {
|
||||
${MODE_ACCESSOR} = "${ChangeDetectionUtil.changeDetectionMode(this.changeDetectionStrategy)}";
|
||||
${CONTEXT_ACCESSOR} = context;
|
||||
${LOCALS_ACCESSOR} = locals;
|
||||
${this._genHydrateDirectives()}
|
||||
${this._genHydrateDetectors()}
|
||||
${PIPE_REGISTRY_ACCESSOR} = pipeRegistry;
|
||||
${PIPES_ACCESSOR} = pipes;
|
||||
${ALREADY_CHECKED_ACCESSOR} = false;
|
||||
}
|
||||
|
||||
|
@ -125,7 +125,7 @@ export class ChangeDetectorJITGenerator {
|
|||
${this._genPipeOnDestroy()}
|
||||
${this._genFieldDefinitions()}
|
||||
${LOCALS_ACCESSOR} = null;
|
||||
${PIPE_REGISTRY_ACCESSOR} = null;
|
||||
${PIPES_ACCESSOR} = null;
|
||||
}
|
||||
|
||||
${typeName}.prototype.hydrated = function() {
|
||||
|
@ -267,10 +267,10 @@ export class ChangeDetectorJITGenerator {
|
|||
return `
|
||||
${CURRENT_PROTO} = ${PROTOS_ACCESSOR}[${protoIndex}];
|
||||
if (${pipe} === ${UTIL}.uninitialized()) {
|
||||
${pipe} = ${PIPE_REGISTRY_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
|
||||
${pipe} = ${PIPES_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
|
||||
} else if (!${pipe}.supports(${context})) {
|
||||
${pipe}.onDestroy();
|
||||
${pipe} = ${PIPE_REGISTRY_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
|
||||
${pipe} = ${PIPES_ACCESSOR}.get('${pipeType}', ${context}, ${cdRef});
|
||||
}
|
||||
|
||||
${newValue} = ${pipe}.transform(${context}, [${argString}]);
|
||||
|
|
|
@ -4,7 +4,7 @@ import {Locals} from 'angular2/src/change_detection/parser/locals';
|
|||
|
||||
import {AbstractChangeDetector} from './abstract_change_detector';
|
||||
import {BindingRecord} from './binding_record';
|
||||
import {PipeRegistry} from './pipes/pipes';
|
||||
import {Pipes} from './pipes/pipes';
|
||||
import {ChangeDetectionUtil, SimpleChange, uninitialized} from './change_detection_util';
|
||||
|
||||
|
||||
|
@ -14,34 +14,34 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
|||
locals: Locals = null;
|
||||
values: List<any>;
|
||||
changes: List<any>;
|
||||
pipes: List<any>;
|
||||
localPipes: List<any>;
|
||||
prevContexts: List<any>;
|
||||
directives: any = null;
|
||||
alreadyChecked: boolean = false;
|
||||
private pipeRegistry: PipeRegistry = null;
|
||||
private pipes: Pipes = null;
|
||||
|
||||
constructor(id: string, private changeControlStrategy: string, private dispatcher: any,
|
||||
private protos: List<ProtoRecord>, private directiveRecords: List<any>) {
|
||||
super(id);
|
||||
this.values = ListWrapper.createFixedSize(protos.length + 1);
|
||||
this.pipes = ListWrapper.createFixedSize(protos.length + 1);
|
||||
this.localPipes = ListWrapper.createFixedSize(protos.length + 1);
|
||||
this.prevContexts = ListWrapper.createFixedSize(protos.length + 1);
|
||||
this.changes = ListWrapper.createFixedSize(protos.length + 1);
|
||||
|
||||
this.values[0] = null;
|
||||
ListWrapper.fill(this.values, uninitialized, 1);
|
||||
ListWrapper.fill(this.pipes, null);
|
||||
ListWrapper.fill(this.localPipes, null);
|
||||
ListWrapper.fill(this.prevContexts, uninitialized);
|
||||
ListWrapper.fill(this.changes, false);
|
||||
}
|
||||
|
||||
hydrate(context: any, locals: Locals, directives: any, pipeRegistry: PipeRegistry): void {
|
||||
hydrate(context: any, locals: Locals, directives: any, pipes: Pipes): void {
|
||||
this.mode = ChangeDetectionUtil.changeDetectionMode(this.changeControlStrategy);
|
||||
this.values[0] = context;
|
||||
this.locals = locals;
|
||||
this.directives = directives;
|
||||
this.alreadyChecked = false;
|
||||
this.pipeRegistry = pipeRegistry;
|
||||
this.pipes = pipes;
|
||||
}
|
||||
|
||||
dehydrate() {
|
||||
|
@ -49,16 +49,16 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
|||
this.values[0] = null;
|
||||
ListWrapper.fill(this.values, uninitialized, 1);
|
||||
ListWrapper.fill(this.changes, false);
|
||||
ListWrapper.fill(this.pipes, null);
|
||||
ListWrapper.fill(this.localPipes, null);
|
||||
ListWrapper.fill(this.prevContexts, uninitialized);
|
||||
this.locals = null;
|
||||
this.pipeRegistry = null;
|
||||
this.pipes = null;
|
||||
}
|
||||
|
||||
_destroyPipes() {
|
||||
for (var i = 0; i < this.pipes.length; ++i) {
|
||||
if (isPresent(this.pipes[i])) {
|
||||
this.pipes[i].onDestroy();
|
||||
for (var i = 0; i < this.localPipes.length; ++i) {
|
||||
if (isPresent(this.localPipes[i])) {
|
||||
this.localPipes[i].onDestroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -270,7 +270,7 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
|||
if (isPresent(storedPipe)) {
|
||||
storedPipe.onDestroy();
|
||||
}
|
||||
var pipe = this.pipeRegistry.get(proto.name, context, this.ref);
|
||||
var pipe = this.pipes.get(proto.name, context, this.ref);
|
||||
this._writePipe(proto, pipe);
|
||||
return pipe;
|
||||
}
|
||||
|
@ -289,9 +289,9 @@ export class DynamicChangeDetector extends AbstractChangeDetector {
|
|||
|
||||
_writeSelf(proto: ProtoRecord, value) { this.values[proto.selfIndex] = value; }
|
||||
|
||||
_readPipe(proto: ProtoRecord) { return this.pipes[proto.selfIndex]; }
|
||||
_readPipe(proto: ProtoRecord) { return this.localPipes[proto.selfIndex]; }
|
||||
|
||||
_writePipe(proto: ProtoRecord, value) { this.pipes[proto.selfIndex] = value; }
|
||||
_writePipe(proto: ProtoRecord, value) { this.localPipes[proto.selfIndex] = value; }
|
||||
|
||||
_setChanged(proto: ProtoRecord, value: boolean) { this.changes[proto.selfIndex] = value; }
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ export interface ChangeDetector {
|
|||
removeChild(cd: ChangeDetector): void;
|
||||
removeShadowDomChild(cd: ChangeDetector): void;
|
||||
remove(): void;
|
||||
hydrate(context: any, locals: Locals, directives: any, pipeRegistry: any): void;
|
||||
hydrate(context: any, locals: Locals, directives: any, pipes: any): void;
|
||||
dehydrate(): void;
|
||||
markPathToRootAsCheckOnce(): void;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
|||
|
||||
@Injectable()
|
||||
@CONST()
|
||||
export class PipeRegistry {
|
||||
export class Pipes {
|
||||
constructor(public config) {}
|
||||
|
||||
get(type: string, obj, cdRef?: ChangeDetectorRef, existingPipe?: Pipe): Pipe {
|
||||
|
|
|
@ -16,7 +16,7 @@ export 'package:angular2/src/change_detection/directive_record.dart'
|
|||
export 'package:angular2/src/change_detection/interfaces.dart'
|
||||
show ChangeDetector, ChangeDetectorDefinition, ProtoChangeDetector;
|
||||
export 'package:angular2/src/change_detection/pipes/pipes.dart'
|
||||
show PipeRegistry;
|
||||
show Pipes;
|
||||
export 'package:angular2/src/change_detection/proto_record.dart'
|
||||
show ProtoRecord;
|
||||
export 'package:angular2/src/change_detection/change_detection_util.dart'
|
||||
|
|
|
@ -20,8 +20,8 @@ import {
|
|||
DynamicChangeDetection,
|
||||
JitChangeDetection,
|
||||
PreGeneratedChangeDetection,
|
||||
PipeRegistry,
|
||||
defaultPipeRegistry
|
||||
Pipes,
|
||||
defaultPipes
|
||||
} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from './exception_handler';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
|
@ -118,7 +118,7 @@ function _injectorBindings(appComponentType): List<Type | Binding | List<any>> {
|
|||
Compiler,
|
||||
CompilerCache,
|
||||
ViewResolver,
|
||||
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
||||
bind(Pipes).toValue(defaultPipes),
|
||||
bind(ChangeDetection).toClass(bestChangeDetection),
|
||||
ViewLoader,
|
||||
DirectiveResolver,
|
||||
|
|
|
@ -52,7 +52,7 @@ import {
|
|||
onAllChangesDone
|
||||
} from 'angular2/src/core/annotations_impl/annotations';
|
||||
import {hasLifecycleHook} from './directive_lifecycle_reflector';
|
||||
import {ChangeDetector, ChangeDetectorRef, PipeRegistry} from 'angular2/change_detection';
|
||||
import {ChangeDetector, ChangeDetectorRef, Pipes} from 'angular2/change_detection';
|
||||
import {QueryList} from './query_list';
|
||||
import {reflector} from 'angular2/src/reflection/reflection';
|
||||
import {DirectiveMetadata} from 'angular2/src/render/api';
|
||||
|
@ -65,7 +65,7 @@ export class StaticKeys {
|
|||
viewContainerId: number;
|
||||
changeDetectorRefId: number;
|
||||
elementRefId: number;
|
||||
pipeRegistryKey: Key;
|
||||
pipesKey: Key;
|
||||
|
||||
constructor() {
|
||||
this.viewManagerId = Key.get(avmModule.AppViewManager).id;
|
||||
|
@ -74,7 +74,7 @@ export class StaticKeys {
|
|||
this.changeDetectorRefId = Key.get(ChangeDetectorRef).id;
|
||||
this.elementRefId = Key.get(ElementRef).id;
|
||||
// not an id because the public API of injector works only with keys and tokens
|
||||
this.pipeRegistryKey = Key.get(PipeRegistry);
|
||||
this.pipesKey = Key.get(Pipes);
|
||||
}
|
||||
|
||||
static instance(): StaticKeys {
|
||||
|
@ -550,9 +550,9 @@ export class ElementInjector extends TreeNode<ElementInjector> implements Depend
|
|||
injector.internalStrategy.hydrate();
|
||||
}
|
||||
|
||||
getPipeRegistry(): PipeRegistry {
|
||||
var pipeRegistryKey = StaticKeys.instance().pipeRegistryKey;
|
||||
return this._injector.getOptional(pipeRegistryKey);
|
||||
getPipes(): Pipes {
|
||||
var pipesKey = StaticKeys.instance().pipesKey;
|
||||
return this._injector.getOptional(pipesKey);
|
||||
}
|
||||
|
||||
hasVariableBinding(name: string): boolean {
|
||||
|
|
|
@ -162,16 +162,15 @@ export class AppViewManagerUtils {
|
|||
this._setUpHostActions(view, elementInjector, i);
|
||||
}
|
||||
}
|
||||
var pipeRegistry = this._getPipeRegistry(imperativelyCreatedInjector, hostElementInjector);
|
||||
view.changeDetector.hydrate(view.context, view.locals, view, pipeRegistry);
|
||||
var pipes = this._getPipes(imperativelyCreatedInjector, hostElementInjector);
|
||||
view.changeDetector.hydrate(view.context, view.locals, view, pipes);
|
||||
}
|
||||
|
||||
_getPipeRegistry(imperativelyCreatedInjector: Injector,
|
||||
hostElementInjector: eli.ElementInjector) {
|
||||
var pipeRegistryKey = eli.StaticKeys.instance().pipeRegistryKey;
|
||||
_getPipes(imperativelyCreatedInjector: Injector, hostElementInjector: eli.ElementInjector) {
|
||||
var pipesKey = eli.StaticKeys.instance().pipesKey;
|
||||
if (isPresent(imperativelyCreatedInjector))
|
||||
return imperativelyCreatedInjector.getOptional(pipeRegistryKey);
|
||||
if (isPresent(hostElementInjector)) return hostElementInjector.getPipeRegistry();
|
||||
return imperativelyCreatedInjector.getOptional(pipesKey);
|
||||
if (isPresent(hostElementInjector)) return hostElementInjector.getPipes();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {Directive, onCheck} from 'angular2/annotations';
|
||||
import {ElementRef} from 'angular2/core';
|
||||
import {PipeRegistry} from 'angular2/src/change_detection/pipes/pipes';
|
||||
import {Pipes} from 'angular2/src/change_detection/pipes/pipes';
|
||||
import {Pipe} from 'angular2/src/change_detection/pipes/pipe';
|
||||
import {Renderer} from 'angular2/src/render/api';
|
||||
import {KeyValueChanges} from 'angular2/src/change_detection/pipes/keyvalue_changes';
|
||||
|
@ -35,8 +35,7 @@ export class CSSClass {
|
|||
_pipe: Pipe;
|
||||
_rawClass;
|
||||
|
||||
constructor(private _pipeRegistry: PipeRegistry, private _ngEl: ElementRef,
|
||||
private _renderer: Renderer) {}
|
||||
constructor(private _pipes: Pipes, private _ngEl: ElementRef, private _renderer: Renderer) {}
|
||||
|
||||
set rawClass(v) {
|
||||
this._cleanupClasses(this._rawClass);
|
||||
|
@ -46,7 +45,7 @@ export class CSSClass {
|
|||
}
|
||||
|
||||
this._rawClass = v;
|
||||
this._pipe = this._pipeRegistry.get(isListLikeIterable(v) ? 'iterableDiff' : 'keyValDiff', v);
|
||||
this._pipe = this._pipes.get(isListLikeIterable(v) ? 'iterableDiff' : 'keyValDiff', v);
|
||||
}
|
||||
|
||||
onCheck(): void {
|
||||
|
|
|
@ -1,12 +1,5 @@
|
|||
import {Directive} from 'angular2/annotations';
|
||||
import {
|
||||
ViewContainerRef,
|
||||
ViewRef,
|
||||
ProtoViewRef,
|
||||
PipeRegistry,
|
||||
onCheck,
|
||||
Pipe
|
||||
} from 'angular2/angular2';
|
||||
import {ViewContainerRef, ViewRef, ProtoViewRef, Pipes, onCheck, Pipe} from 'angular2/angular2';
|
||||
import {isPresent, isBlank} from 'angular2/src/facade/lang';
|
||||
|
||||
/**
|
||||
|
@ -47,7 +40,7 @@ export class NgFor {
|
|||
_pipe: Pipe;
|
||||
|
||||
constructor(private viewContainer: ViewContainerRef, private protoViewRef: ProtoViewRef,
|
||||
private pipes: PipeRegistry) {}
|
||||
private pipes: Pipes) {}
|
||||
|
||||
set ngForOf(value: any) {
|
||||
this._ngForOf = value;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import {Directive, onCheck} from 'angular2/annotations';
|
||||
import {ElementRef} from 'angular2/core';
|
||||
import {Pipe} from 'angular2/src/change_detection/pipes/pipe';
|
||||
import {PipeRegistry} from 'angular2/src/change_detection/pipes/pipes';
|
||||
import {Pipes} from 'angular2/src/change_detection/pipes/pipes';
|
||||
import {KeyValueChanges} from 'angular2/src/change_detection/pipes/keyvalue_changes';
|
||||
import {isPresent, print} from 'angular2/src/facade/lang';
|
||||
import {Renderer} from 'angular2/src/render/api';
|
||||
|
@ -34,12 +34,11 @@ export class NgStyle {
|
|||
_pipe: Pipe;
|
||||
_rawStyle;
|
||||
|
||||
constructor(private _pipeRegistry: PipeRegistry, private _ngEl: ElementRef,
|
||||
private _renderer: Renderer) {}
|
||||
constructor(private _pipes: Pipes, private _ngEl: ElementRef, private _renderer: Renderer) {}
|
||||
|
||||
set rawStyle(v) {
|
||||
this._rawStyle = v;
|
||||
this._pipe = this._pipeRegistry.get('keyValDiff', this._rawStyle);
|
||||
this._pipe = this._pipes.get('keyValDiff', this._rawStyle);
|
||||
}
|
||||
|
||||
onCheck() {
|
||||
|
|
|
@ -7,8 +7,8 @@ import {
|
|||
Lexer,
|
||||
ChangeDetection,
|
||||
DynamicChangeDetection,
|
||||
PipeRegistry,
|
||||
defaultPipeRegistry
|
||||
Pipes,
|
||||
defaultPipes
|
||||
} from 'angular2/change_detection';
|
||||
import {ExceptionHandler} from 'angular2/src/core/exception_handler';
|
||||
import {ViewLoader} from 'angular2/src/render/dom/compiler/view_loader';
|
||||
|
@ -101,7 +101,7 @@ function _getAppBindings() {
|
|||
Compiler,
|
||||
CompilerCache,
|
||||
bind(ViewResolver).toClass(MockViewResolver),
|
||||
bind(PipeRegistry).toValue(defaultPipeRegistry),
|
||||
bind(Pipes).toValue(defaultPipes),
|
||||
bind(ChangeDetection).toClass(DynamicChangeDetection),
|
||||
ViewLoader,
|
||||
DynamicComponentLoader,
|
||||
|
|
|
@ -125,7 +125,7 @@ class _CodegenState {
|
|||
buf.write('''\n
|
||||
class $_changeDetectorTypeName extends $_BASE_CLASS {
|
||||
final dynamic $_DISPATCHER_ACCESSOR;
|
||||
$_GEN_PREFIX.PipeRegistry $_PIPE_REGISTRY_ACCESSOR;
|
||||
$_GEN_PREFIX.Pipes $_PIPES_ACCESSOR;
|
||||
final $_GEN_PREFIX.List<$_GEN_PREFIX.ProtoRecord> $_PROTOS_ACCESSOR;
|
||||
final $_GEN_PREFIX.List<$_GEN_PREFIX.DirectiveRecord>
|
||||
$_DIRECTIVES_ACCESSOR;
|
||||
|
@ -172,14 +172,14 @@ class _CodegenState {
|
|||
${_getCallOnAllChangesDoneBody()}
|
||||
}
|
||||
|
||||
void hydrate($_contextTypeName context, locals, directives, pipeRegistry) {
|
||||
void hydrate($_contextTypeName context, locals, directives, pipes) {
|
||||
$_MODE_ACCESSOR = '$_changeDetectionMode';
|
||||
$_CONTEXT_ACCESSOR = context;
|
||||
$_LOCALS_ACCESSOR = locals;
|
||||
${_genHydrateDirectives()}
|
||||
${_genHydrateDetectors()}
|
||||
$_ALREADY_CHECKED_ACCESSOR = false;
|
||||
$_PIPE_REGISTRY_ACCESSOR = pipeRegistry;
|
||||
$_PIPES_ACCESSOR = pipes;
|
||||
}
|
||||
|
||||
void dehydrate() {
|
||||
|
@ -190,7 +190,7 @@ class _CodegenState {
|
|||
: '$f = $_UTIL.uninitialized();';
|
||||
}).join('')}
|
||||
$_LOCALS_ACCESSOR = null;
|
||||
$_PIPE_REGISTRY_ACCESSOR = null;
|
||||
$_PIPES_ACCESSOR = null;
|
||||
}
|
||||
|
||||
hydrated() => $_CONTEXT_ACCESSOR != null;
|
||||
|
@ -327,10 +327,10 @@ class _CodegenState {
|
|||
return '''
|
||||
$_CURRENT_PROTO = $_PROTOS_ACCESSOR[$protoIndex];
|
||||
if ($_IDENTICAL_CHECK_FN($pipe, $_UTIL.uninitialized())) {
|
||||
$pipe = $_PIPE_REGISTRY_ACCESSOR.get('$pipeType', $context, $cdRef);
|
||||
$pipe = $_PIPES_ACCESSOR.get('$pipeType', $context, $cdRef);
|
||||
} else if (!$pipe.supports($context)) {
|
||||
$pipe.onDestroy();
|
||||
$pipe = $_PIPE_REGISTRY_ACCESSOR.get('$pipeType', $context, $cdRef);
|
||||
$pipe = $_PIPES_ACCESSOR.get('$pipeType', $context, $cdRef);
|
||||
}
|
||||
|
||||
$newValue = $pipe.transform($context, [$argString]);
|
||||
|
@ -542,6 +542,6 @@ const _LOCALS_ACCESSOR = '_locals';
|
|||
const _MODE_ACCESSOR = 'mode';
|
||||
const _PREGEN_PROTO_CHANGE_DETECTOR_IMPORT =
|
||||
'package:angular2/src/change_detection/pregen_proto_change_detector.dart';
|
||||
const _PIPE_REGISTRY_ACCESSOR = '_pipeRegistry';
|
||||
const _PIPES_ACCESSOR = '_pipes';
|
||||
const _PROTOS_ACCESSOR = '_protos';
|
||||
const _UTIL = '$_GEN_PREFIX.ChangeDetectionUtil';
|
||||
|
|
|
@ -29,7 +29,7 @@ import {
|
|||
BindingRecord,
|
||||
DirectiveRecord,
|
||||
DirectiveIndex,
|
||||
PipeRegistry,
|
||||
Pipes,
|
||||
Pipe,
|
||||
CHECK_ALWAYS,
|
||||
CHECK_ONCE,
|
||||
|
@ -324,7 +324,7 @@ export function main() {
|
|||
|
||||
describe('pipes', () => {
|
||||
it('should pass a change record to the dispatcher', () => {
|
||||
var registry = new FakePipeRegistry('pipe', () => new CountingPipe());
|
||||
var registry = new FakePipes('pipe', () => new CountingPipe());
|
||||
var person = new Person('bob');
|
||||
var val = _createChangeDetector('name | pipe', person, registry);
|
||||
val.changeDetector.detectChanges();
|
||||
|
@ -332,7 +332,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should support arguments in pipes', () => {
|
||||
var registry = new FakePipeRegistry('pipe', () => new MultiArgPipe());
|
||||
var registry = new FakePipes('pipe', () => new MultiArgPipe());
|
||||
var address = new Address('two');
|
||||
var person = new Person('value', address);
|
||||
var val = _createChangeDetector("name | pipe:'one':address.city", person, registry);
|
||||
|
@ -749,7 +749,7 @@ export function main() {
|
|||
|
||||
it('should destroy all active pipes during dehyration', () => {
|
||||
var pipe = new OncePipe();
|
||||
var registry = new FakePipeRegistry('pipe', () => pipe);
|
||||
var registry = new FakePipes('pipe', () => pipe);
|
||||
var cd = _createChangeDetector('name | pipe', new Person('bob'), registry).changeDetector;
|
||||
|
||||
cd.detectChanges();
|
||||
|
@ -775,7 +775,7 @@ export function main() {
|
|||
|
||||
describe('pipes', () => {
|
||||
it('should support pipes', () => {
|
||||
var registry = new FakePipeRegistry('pipe', () => new CountingPipe());
|
||||
var registry = new FakePipes('pipe', () => new CountingPipe());
|
||||
var ctx = new Person('Megatron');
|
||||
|
||||
var val = _createChangeDetector('name | pipe', ctx, registry);
|
||||
|
@ -791,7 +791,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should lookup pipes in the registry when the context is not supported', () => {
|
||||
var registry = new FakePipeRegistry('pipe', () => new OncePipe());
|
||||
var registry = new FakePipes('pipe', () => new OncePipe());
|
||||
var ctx = new Person('Megatron');
|
||||
|
||||
var cd = _createChangeDetector('name | pipe', ctx, registry).changeDetector;
|
||||
|
@ -808,7 +808,7 @@ export function main() {
|
|||
|
||||
it('should invoke onDestroy on a pipe before switching to another one', () => {
|
||||
var pipe = new OncePipe();
|
||||
var registry = new FakePipeRegistry('pipe', () => pipe);
|
||||
var registry = new FakePipes('pipe', () => pipe);
|
||||
var ctx = new Person('Megatron');
|
||||
|
||||
var cd = _createChangeDetector('name | pipe', ctx, registry).changeDetector;
|
||||
|
@ -824,7 +824,7 @@ export function main() {
|
|||
'of the encompassing component into a pipe',
|
||||
() => {
|
||||
|
||||
var registry = new FakePipeRegistry('pipe', () => new IdentityPipe());
|
||||
var registry = new FakePipes('pipe', () => new IdentityPipe());
|
||||
var cd =
|
||||
_createChangeDetector('name | pipe', new Person('bob'), registry).changeDetector;
|
||||
|
||||
|
@ -835,7 +835,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should do nothing when no change', () => {
|
||||
var registry = new FakePipeRegistry('pipe', () => new IdentityPipe());
|
||||
var registry = new FakePipes('pipe', () => new IdentityPipe());
|
||||
var ctx = new Person('Megatron');
|
||||
|
||||
var val = _createChangeDetector('name | pipe', ctx, registry);
|
||||
|
@ -851,7 +851,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it('should unwrap the wrapped value', () => {
|
||||
var registry = new FakePipeRegistry('pipe', () => new WrappedPipe());
|
||||
var registry = new FakePipes('pipe', () => new WrappedPipe());
|
||||
var ctx = new Person('Megatron');
|
||||
|
||||
var val = _createChangeDetector('name | pipe', ctx, registry);
|
||||
|
@ -915,7 +915,7 @@ class MultiArgPipe implements Pipe {
|
|||
onDestroy(): void {}
|
||||
}
|
||||
|
||||
class FakePipeRegistry extends PipeRegistry {
|
||||
class FakePipes extends Pipes {
|
||||
numberOfLookups: number;
|
||||
pipeType: string;
|
||||
factory: Function;
|
||||
|
|
|
@ -11,7 +11,7 @@ import {
|
|||
SpyPipeFactory
|
||||
} from 'angular2/test_lib';
|
||||
|
||||
import {PipeRegistry} from 'angular2/src/change_detection/pipes/pipes';
|
||||
import {Pipes} from 'angular2/src/change_detection/pipes/pipes';
|
||||
|
||||
export function main() {
|
||||
describe("pipe registry", () => {
|
||||
|
@ -30,7 +30,7 @@ export function main() {
|
|||
});
|
||||
|
||||
it("should return an existing pipe if it can support the passed in object", () => {
|
||||
var r = new PipeRegistry({"type": []});
|
||||
var r = new Pipes({"type": []});
|
||||
|
||||
firstPipe.spy("supports").andReturn(true);
|
||||
|
||||
|
@ -43,7 +43,7 @@ export function main() {
|
|||
firstPipeFactory.spy("supports").andReturn(true);
|
||||
firstPipeFactory.spy("create").andReturn(secondPipe);
|
||||
|
||||
var r = new PipeRegistry({"type": [firstPipeFactory]});
|
||||
var r = new Pipes({"type": [firstPipeFactory]});
|
||||
|
||||
expect(r.get("type", "some object", null, firstPipe)).toEqual(secondPipe);
|
||||
expect(firstPipe.spy("onDestroy")).toHaveBeenCalled();
|
||||
|
@ -56,19 +56,19 @@ export function main() {
|
|||
secondPipeFactory.spy("supports").andReturn(true);
|
||||
secondPipeFactory.spy("create").andReturn(secondPipe);
|
||||
|
||||
var r = new PipeRegistry({"type": [firstPipeFactory, secondPipeFactory]});
|
||||
var r = new Pipes({"type": [firstPipeFactory, secondPipeFactory]});
|
||||
|
||||
expect(r.get("type", "some object")).toBe(secondPipe);
|
||||
});
|
||||
|
||||
it("should throw when no matching type", () => {
|
||||
var r = new PipeRegistry({});
|
||||
var r = new Pipes({});
|
||||
expect(() => r.get("unknown", "some object"))
|
||||
.toThrowError(`Cannot find 'unknown' pipe supporting object 'some object'`);
|
||||
});
|
||||
|
||||
it("should throw when no matching pipe", () => {
|
||||
var r = new PipeRegistry({"type": []});
|
||||
var r = new Pipes({"type": []});
|
||||
|
||||
expect(() => r.get("type", "some object"))
|
||||
.toThrowError(`Cannot find 'type' pipe supporting object 'some object'`);
|
||||
|
|
|
@ -48,8 +48,8 @@ import {
|
|||
} from 'angular2/di';
|
||||
import {
|
||||
PipeFactory,
|
||||
PipeRegistry,
|
||||
defaultPipeRegistry,
|
||||
Pipes,
|
||||
defaultPipes,
|
||||
ChangeDetection,
|
||||
DynamicChangeDetection,
|
||||
Pipe,
|
||||
|
@ -1402,13 +1402,13 @@ class PushCmpWithRef {
|
|||
}
|
||||
|
||||
@Injectable()
|
||||
class PipeRegistryWithDouble extends PipeRegistry {
|
||||
class PipesWithDouble extends Pipes {
|
||||
constructor() { super({"double": [new DoublePipeFactory()]}); }
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'my-comp-with-pipes',
|
||||
viewInjector: [new Binding(PipeRegistry, {toClass: PipeRegistryWithDouble})]
|
||||
viewInjector: [new Binding(Pipes, {toClass: PipesWithDouble})]
|
||||
})
|
||||
@View({directives: []})
|
||||
@Injectable()
|
||||
|
|
|
@ -27,7 +27,7 @@ void initReflector(reflector) {
|
|||
}
|
||||
class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
|
||||
final dynamic _dispatcher;
|
||||
_gen.PipeRegistry _pipeRegistry;
|
||||
_gen.Pipes _pipes;
|
||||
final _gen.List<_gen.ProtoRecord> _protos;
|
||||
final _gen.List<_gen.DirectiveRecord> _directiveRecords;
|
||||
dynamic _locals = null;
|
||||
|
@ -100,13 +100,13 @@ class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
|
|||
_dispatcher.notifyOnAllChangesDone();
|
||||
}
|
||||
|
||||
void hydrate(MyComponent context, locals, directives, pipeRegistry) {
|
||||
void hydrate(MyComponent context, locals, directives, pipes) {
|
||||
mode = 'ALWAYS_CHECK';
|
||||
_context = context;
|
||||
_locals = locals;
|
||||
|
||||
_alreadyChecked = false;
|
||||
_pipeRegistry = pipeRegistry;
|
||||
_pipes = pipes;
|
||||
}
|
||||
|
||||
void dehydrate() {
|
||||
|
@ -114,7 +114,7 @@ class _MyComponent_ChangeDetector0 extends _gen.AbstractChangeDetector {
|
|||
_myNum0 = _gen.ChangeDetectionUtil.uninitialized();
|
||||
_interpolate1 = _gen.ChangeDetectionUtil.uninitialized();
|
||||
_locals = null;
|
||||
_pipeRegistry = null;
|
||||
_pipes = null;
|
||||
}
|
||||
|
||||
hydrated() => _context != null;
|
||||
|
|
Loading…
Reference in New Issue