@ -45,6 +45,7 @@ function _simpleChange(previousValue, currentValue): SimpleChange {
|
||||
return s;
|
||||
}
|
||||
|
||||
/* tslint:disable:requireParameterType */
|
||||
export class ChangeDetectionUtil {
|
||||
static uninitialized(): Object { return uninitialized; }
|
||||
|
||||
|
@ -3,11 +3,11 @@ import {List, Map, ListWrapper, StringMapWrapper} from "angular2/src/facade/coll
|
||||
import {Locals} from "./locals";
|
||||
|
||||
export class AST {
|
||||
eval(context, locals: Locals) { throw new BaseException("Not supported"); }
|
||||
eval(context: any, locals: Locals): any { throw new BaseException("Not supported"); }
|
||||
|
||||
get isAssignable(): boolean { return false; }
|
||||
|
||||
assign(context, locals: Locals, value) { throw new BaseException("Not supported"); }
|
||||
assign(context: any, locals: Locals, value: any) { throw new BaseException("Not supported"); }
|
||||
|
||||
visit(visitor: AstVisitor): any { return null; }
|
||||
|
||||
@ -15,7 +15,7 @@ export class AST {
|
||||
}
|
||||
|
||||
export class EmptyExpr extends AST {
|
||||
eval(context, locals: Locals): any { return null; }
|
||||
eval(context: any, locals: Locals): any { return null; }
|
||||
|
||||
visit(visitor: AstVisitor) {
|
||||
// do nothing
|
||||
@ -23,7 +23,7 @@ export class EmptyExpr extends AST {
|
||||
}
|
||||
|
||||
export class ImplicitReceiver extends AST {
|
||||
eval(context, locals: Locals): any { return context; }
|
||||
eval(context: any, locals: Locals): any { return context; }
|
||||
|
||||
visit(visitor: AstVisitor): any { return visitor.visitImplicitReceiver(this); }
|
||||
}
|
||||
@ -34,7 +34,7 @@ export class ImplicitReceiver extends AST {
|
||||
export class Chain extends AST {
|
||||
constructor(public expressions: List<any>) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var result;
|
||||
for (var i = 0; i < this.expressions.length; i++) {
|
||||
var last = this.expressions[i].eval(context, locals);
|
||||
@ -49,7 +49,7 @@ export class Chain extends AST {
|
||||
export class Conditional extends AST {
|
||||
constructor(public condition: AST, public trueExp: AST, public falseExp: AST) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
if (this.condition.eval(context, locals)) {
|
||||
return this.trueExp.eval(context, locals);
|
||||
} else {
|
||||
@ -63,7 +63,7 @@ export class Conditional extends AST {
|
||||
export class If extends AST {
|
||||
constructor(public condition: AST, public trueExp: AST, public falseExp?: AST) { super(); }
|
||||
|
||||
eval(context, locals) {
|
||||
eval(context: any, locals: Locals) {
|
||||
if (this.condition.eval(context, locals)) {
|
||||
this.trueExp.eval(context, locals);
|
||||
} else if (isPresent(this.falseExp)) {
|
||||
@ -80,7 +80,7 @@ export class AccessMember extends AST {
|
||||
super();
|
||||
}
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
|
||||
locals.contains(this.name)) {
|
||||
return locals.get(this.name);
|
||||
@ -92,7 +92,7 @@ export class AccessMember extends AST {
|
||||
|
||||
get isAssignable(): boolean { return true; }
|
||||
|
||||
assign(context, locals: Locals, value): any {
|
||||
assign(context: any, locals: Locals, value: any): any {
|
||||
var evaluatedContext = this.receiver.eval(context, locals);
|
||||
|
||||
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
|
||||
@ -112,7 +112,7 @@ export class SafeAccessMember extends AST {
|
||||
super();
|
||||
}
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var evaluatedReceiver = this.receiver.eval(context, locals);
|
||||
return isBlank(evaluatedReceiver) ? null : this.getter(evaluatedReceiver);
|
||||
}
|
||||
@ -123,7 +123,7 @@ export class SafeAccessMember extends AST {
|
||||
export class KeyedAccess extends AST {
|
||||
constructor(public obj: AST, public key: AST) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var obj: any = this.obj.eval(context, locals);
|
||||
var key: any = this.key.eval(context, locals);
|
||||
return obj[key];
|
||||
@ -131,7 +131,7 @@ export class KeyedAccess extends AST {
|
||||
|
||||
get isAssignable(): boolean { return true; }
|
||||
|
||||
assign(context, locals: Locals, value): any {
|
||||
assign(context: any, locals: Locals, value: any): any {
|
||||
var obj: any = this.obj.eval(context, locals);
|
||||
var key: any = this.key.eval(context, locals);
|
||||
obj[key] = value;
|
||||
@ -150,7 +150,7 @@ export class BindingPipe extends AST {
|
||||
export class LiteralPrimitive extends AST {
|
||||
constructor(public value) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any { return this.value; }
|
||||
eval(context: any, locals: Locals): any { return this.value; }
|
||||
|
||||
visit(visitor: AstVisitor): any { return visitor.visitLiteralPrimitive(this); }
|
||||
}
|
||||
@ -158,7 +158,7 @@ export class LiteralPrimitive extends AST {
|
||||
export class LiteralArray extends AST {
|
||||
constructor(public expressions: List<any>) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
return ListWrapper.map(this.expressions, (e) => e.eval(context, locals));
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ export class LiteralArray extends AST {
|
||||
export class LiteralMap extends AST {
|
||||
constructor(public keys: List<any>, public values: List<any>) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var res = StringMapWrapper.create();
|
||||
for (var i = 0; i < this.keys.length; ++i) {
|
||||
StringMapWrapper.set(res, this.keys[i], this.values[i].eval(context, locals));
|
||||
@ -182,7 +182,7 @@ export class LiteralMap extends AST {
|
||||
export class Interpolation extends AST {
|
||||
constructor(public strings: List<any>, public expressions: List<any>) { super(); }
|
||||
|
||||
eval(context, locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
throw new BaseException("evaluating an Interpolation is not supported");
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ export class Interpolation extends AST {
|
||||
export class Binary extends AST {
|
||||
constructor(public operation: string, public left: AST, public right: AST) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var left: any = this.left.eval(context, locals);
|
||||
switch (this.operation) {
|
||||
case '&&':
|
||||
@ -243,15 +243,15 @@ export class Binary extends AST {
|
||||
export class PrefixNot extends AST {
|
||||
constructor(public expression: AST) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any { return !this.expression.eval(context, locals); }
|
||||
eval(context: any, locals: Locals): any { return !this.expression.eval(context, locals); }
|
||||
|
||||
visit(visitor: AstVisitor): any { return visitor.visitPrefixNot(this); }
|
||||
}
|
||||
|
||||
export class Assignment extends AST {
|
||||
constructor(public target: AST, public value: AST) { super(); }
|
||||
constructor(public target: AST, public value: any) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
return this.target.assign(context, locals, this.value.eval(context, locals));
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ export class MethodCall extends AST {
|
||||
super();
|
||||
}
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var evaluatedArgs = evalList(context, locals, this.args);
|
||||
if (this.receiver instanceof ImplicitReceiver && isPresent(locals) &&
|
||||
locals.contains(this.name)) {
|
||||
@ -285,7 +285,7 @@ export class SafeMethodCall extends AST {
|
||||
super();
|
||||
}
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var evaluatedReceiver = this.receiver.eval(context, locals);
|
||||
if (isBlank(evaluatedReceiver)) return null;
|
||||
var evaluatedArgs = evalList(context, locals, this.args);
|
||||
@ -298,7 +298,7 @@ export class SafeMethodCall extends AST {
|
||||
export class FunctionCall extends AST {
|
||||
constructor(public target: AST, public args: List<any>) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any {
|
||||
eval(context: any, locals: Locals): any {
|
||||
var obj: any = this.target.eval(context, locals);
|
||||
if (!(obj instanceof Function)) {
|
||||
throw new BaseException(`${obj} is not a function`);
|
||||
@ -312,11 +312,13 @@ export class FunctionCall extends AST {
|
||||
export class ASTWithSource extends AST {
|
||||
constructor(public ast: AST, public source: string, public location: string) { super(); }
|
||||
|
||||
eval(context, locals: Locals): any { return this.ast.eval(context, locals); }
|
||||
eval(context: any, locals: Locals): any { return this.ast.eval(context, locals); }
|
||||
|
||||
get isAssignable(): boolean { return this.ast.isAssignable; }
|
||||
|
||||
assign(context, locals: Locals, value): any { return this.ast.assign(context, locals, value); }
|
||||
assign(context: any, locals: Locals, value: any): any {
|
||||
return this.ast.assign(context, locals, value);
|
||||
}
|
||||
|
||||
visit(visitor: AstVisitor): any { return this.ast.visit(visitor); }
|
||||
|
||||
|
@ -28,7 +28,7 @@ export class Locals {
|
||||
throw new BaseException(`Cannot find '${name}'`);
|
||||
}
|
||||
|
||||
set(name: string, value): void {
|
||||
set(name: string, value: any): void {
|
||||
// TODO(rado): consider removing this check if we can guarantee this is not
|
||||
// exposed to the public API.
|
||||
// TODO: vsavkin maybe it should check only the local map
|
||||
|
@ -479,7 +479,7 @@ class _ParseAST {
|
||||
return new LiteralMap(keys, values);
|
||||
}
|
||||
|
||||
parseAccessMemberOrMethodCall(receiver, isSafe: boolean = false): AST {
|
||||
parseAccessMemberOrMethodCall(receiver: AST, isSafe: boolean = false): AST {
|
||||
let id = this.expectIdentifierOrKeyword();
|
||||
|
||||
if (this.optionalCharacter($LPAREN)) {
|
||||
|
@ -83,7 +83,7 @@ export class DatePipe extends BasePipe implements PipeFactory {
|
||||
};
|
||||
|
||||
|
||||
transform(value, args: List<any>): string {
|
||||
transform(value: any, args: List<any>): string {
|
||||
var pattern: string = isPresent(args) && args.length > 0 ? args[0] : 'mediumDate';
|
||||
if (isNumber(value)) {
|
||||
value = DateWrapper.fromMillis(value);
|
||||
@ -94,7 +94,7 @@ export class DatePipe extends BasePipe implements PipeFactory {
|
||||
return DateFormatter.format(value, defaultLocale, pattern);
|
||||
}
|
||||
|
||||
supports(obj): boolean { return isDate(obj) || isNumber(obj); }
|
||||
supports(obj: any): boolean { return isDate(obj) || isNumber(obj); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
||||
@CONST()
|
||||
export class IterableChangesFactory implements PipeFactory {
|
||||
supports(obj): boolean { return IterableChanges.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return IterableChanges.supportsObj(obj); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new IterableChanges(); }
|
||||
}
|
||||
@ -44,9 +44,9 @@ export class IterableChanges extends BasePipe {
|
||||
|
||||
constructor() { super(); }
|
||||
|
||||
static supportsObj(obj): boolean { return isListLikeIterable(obj); }
|
||||
static supportsObj(obj: Object): boolean { return isListLikeIterable(obj); }
|
||||
|
||||
supports(obj): boolean { return IterableChanges.supportsObj(obj); }
|
||||
supports(obj: Object): boolean { return IterableChanges.supportsObj(obj); }
|
||||
|
||||
get collection() { return this._collection; }
|
||||
|
||||
@ -87,7 +87,7 @@ export class IterableChanges extends BasePipe {
|
||||
}
|
||||
}
|
||||
|
||||
transform(collection, args: List<any> = null): any {
|
||||
transform(collection: any, args: List<any> = null): any {
|
||||
if (this.check(collection)) {
|
||||
return WrappedValue.wrap(this);
|
||||
} else {
|
||||
@ -96,7 +96,7 @@ export class IterableChanges extends BasePipe {
|
||||
}
|
||||
|
||||
// todo(vicb): optim for UnmodifiableListView (frozen arrays)
|
||||
check(collection): boolean {
|
||||
check(collection: any): boolean {
|
||||
this._reset();
|
||||
|
||||
var record: CollectionChangeRecord = this._itHead;
|
||||
@ -524,7 +524,7 @@ class _DuplicateItemRecordList {
|
||||
|
||||
// Returns a CollectionChangeRecord having CollectionChangeRecord.item == item and
|
||||
// CollectionChangeRecord.currentIndex >= afterIndex
|
||||
get(item, afterIndex: int): CollectionChangeRecord {
|
||||
get(item: any, afterIndex: int): CollectionChangeRecord {
|
||||
var record: CollectionChangeRecord;
|
||||
for (record = this._head; record !== null; record = record._nextDup) {
|
||||
if ((afterIndex === null || afterIndex < record.currentIndex) &&
|
||||
@ -588,7 +588,7 @@ class _DuplicateMap {
|
||||
* Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
|
||||
* have any more `a`s needs to return the last `a` not the first or second.
|
||||
*/
|
||||
get(value, afterIndex = null): CollectionChangeRecord {
|
||||
get(value: any, afterIndex: int = null): CollectionChangeRecord {
|
||||
var key = getMapKey(value);
|
||||
|
||||
var recordList = this.map.get(key);
|
||||
|
@ -27,7 +27,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
*/
|
||||
@CONST()
|
||||
export class JsonPipe extends BasePipe implements PipeFactory {
|
||||
transform(value, args: List<any> = null): string { return Json.stringify(value); }
|
||||
transform(value: any, args: List<any> = null): string { return Json.stringify(value); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import {WrappedValue, BasePipe, Pipe, PipeFactory} from './pipe';
|
||||
|
||||
@CONST()
|
||||
export class KeyValueChangesFactory implements PipeFactory {
|
||||
supports(obj): boolean { return KeyValueChanges.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return KeyValueChanges.supportsObj(obj); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new KeyValueChanges(); }
|
||||
}
|
||||
@ -21,11 +21,11 @@ export class KeyValueChanges extends BasePipe {
|
||||
private _removalsHead: KVChangeRecord = null;
|
||||
private _removalsTail: KVChangeRecord = null;
|
||||
|
||||
static supportsObj(obj): boolean { return obj instanceof Map || isJsObject(obj); }
|
||||
static supportsObj(obj: any): boolean { return obj instanceof Map || isJsObject(obj); }
|
||||
|
||||
supports(obj): boolean { return KeyValueChanges.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return KeyValueChanges.supportsObj(obj); }
|
||||
|
||||
transform(map, args: List<any> = null): any {
|
||||
transform(map: Map<any, any>, args: List<any> = null): any {
|
||||
if (this.check(map)) {
|
||||
return WrappedValue.wrap(this);
|
||||
} else {
|
||||
@ -73,7 +73,7 @@ export class KeyValueChanges extends BasePipe {
|
||||
}
|
||||
}
|
||||
|
||||
check(map): boolean {
|
||||
check(map: Map<any, any>): boolean {
|
||||
this._reset();
|
||||
var records = this._records;
|
||||
var oldSeqRecord: KVChangeRecord = this._mapHead;
|
||||
|
@ -51,11 +51,11 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
* {{ 'abcdefghij' | limitTo: -100 }} // output is 'abcdefghij'
|
||||
*/
|
||||
export class LimitToPipe implements Pipe {
|
||||
static supportsObj(obj): boolean { return isString(obj) || isArray(obj); }
|
||||
static supportsObj(obj: any): boolean { return isString(obj) || isArray(obj); }
|
||||
|
||||
supports(obj): boolean { return LimitToPipe.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return LimitToPipe.supportsObj(obj); }
|
||||
|
||||
transform(value, args: List<any> = null): any {
|
||||
transform(value: any, args: List<any> = null): any {
|
||||
if (isBlank(args) || args.length == 0) {
|
||||
throw new BaseException('limitTo pipe requires one argument');
|
||||
}
|
||||
@ -76,7 +76,7 @@ export class LimitToPipe implements Pipe {
|
||||
|
||||
@CONST()
|
||||
export class LimitToPipeFactory implements PipeFactory {
|
||||
supports(obj): boolean { return LimitToPipe.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return LimitToPipe.supportsObj(obj); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new LimitToPipe(); }
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
export class LowerCasePipe implements Pipe {
|
||||
_latestValue: string = null;
|
||||
|
||||
supports(str): boolean { return isString(str); }
|
||||
supports(str: any): boolean { return isString(str); }
|
||||
|
||||
onDestroy(): void { this._latestValue = null; }
|
||||
|
||||
@ -41,7 +41,7 @@ export class LowerCasePipe implements Pipe {
|
||||
|
||||
@CONST()
|
||||
export class LowerCaseFactory implements PipeFactory {
|
||||
supports(str): boolean { return isString(str); }
|
||||
supports(str: any): boolean { return isString(str); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new LowerCasePipe(); }
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
|
||||
@CONST()
|
||||
export class NullPipeFactory implements PipeFactory {
|
||||
supports(obj): boolean { return NullPipe.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return NullPipe.supportsObj(obj); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new NullPipe(); }
|
||||
}
|
||||
@ -12,11 +12,11 @@ export class NullPipeFactory implements PipeFactory {
|
||||
export class NullPipe extends BasePipe {
|
||||
called: boolean = false;
|
||||
|
||||
static supportsObj(obj): boolean { return isBlank(obj); }
|
||||
static supportsObj(obj: any): boolean { return isBlank(obj); }
|
||||
|
||||
supports(obj): boolean { return NullPipe.supportsObj(obj); }
|
||||
supports(obj: any): boolean { return NullPipe.supportsObj(obj); }
|
||||
|
||||
transform(value, args: List<any> = null): WrappedValue {
|
||||
transform(value: any, args: List<any> = null): WrappedValue {
|
||||
if (!this.called) {
|
||||
this.called = true;
|
||||
return WrappedValue.wrap(null);
|
||||
|
@ -46,7 +46,7 @@ export class NumberPipe extends BasePipe implements PipeFactory {
|
||||
});
|
||||
}
|
||||
|
||||
supports(obj): boolean { return isNumber(obj); }
|
||||
supports(obj: any): boolean { return isNumber(obj); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return this; }
|
||||
}
|
||||
@ -78,7 +78,7 @@ export class NumberPipe extends BasePipe implements PipeFactory {
|
||||
*/
|
||||
@CONST()
|
||||
export class DecimalPipe extends NumberPipe {
|
||||
transform(value, args: any[]): string {
|
||||
transform(value: any, args: any[]): string {
|
||||
var digits: string = ListWrapper.first(args);
|
||||
return NumberPipe._format(value, NumberFormatStyle.DECIMAL, digits);
|
||||
}
|
||||
@ -95,7 +95,7 @@ export class DecimalPipe extends NumberPipe {
|
||||
*/
|
||||
@CONST()
|
||||
export class PercentPipe extends NumberPipe {
|
||||
transform(value, args: any[]): string {
|
||||
transform(value: any, args: any[]): string {
|
||||
var digits: string = ListWrapper.first(args);
|
||||
return NumberPipe._format(value, NumberFormatStyle.PERCENT, digits);
|
||||
}
|
||||
@ -116,7 +116,7 @@ export class PercentPipe extends NumberPipe {
|
||||
*/
|
||||
@CONST()
|
||||
export class CurrencyPipe extends NumberPipe {
|
||||
transform(value, args: any[]): string {
|
||||
transform(value: any, args: any[]): string {
|
||||
var currencyCode: string = isPresent(args) && args.length > 0 ? args[0] : 'USD';
|
||||
var symbolDisplay: boolean = isPresent(args) && args.length > 1 ? args[1] : false;
|
||||
var digits: string = isPresent(args) && args.length > 2 ? args[2] : null;
|
||||
|
@ -36,7 +36,7 @@ export class ObservablePipe implements Pipe {
|
||||
|
||||
constructor(public _ref: ChangeDetectorRef) {}
|
||||
|
||||
supports(obs): boolean { return ObservableWrapper.isObservable(obs); }
|
||||
supports(obs: any): boolean { return ObservableWrapper.isObservable(obs); }
|
||||
|
||||
onDestroy(): void {
|
||||
if (isPresent(this._subscription)) {
|
||||
@ -88,7 +88,7 @@ export class ObservablePipe implements Pipe {
|
||||
*/
|
||||
@CONST()
|
||||
export class ObservablePipeFactory implements PipeFactory {
|
||||
supports(obs): boolean { return ObservableWrapper.isObservable(obs); }
|
||||
supports(obs: any): boolean { return ObservableWrapper.isObservable(obs); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new ObservablePipe(cdRef); }
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ export interface Pipe {
|
||||
*/
|
||||
@CONST()
|
||||
export class BasePipe implements Pipe {
|
||||
supports(obj): boolean { return true; }
|
||||
supports(obj: any): boolean { return true; }
|
||||
onDestroy(): void {}
|
||||
transform(value: any, args: List<any>): any { return _abstract(); }
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ export class Pipes {
|
||||
config: StringMap<string, PipeFactory[]>;
|
||||
constructor(config: StringMap<string, PipeFactory[]>) { this.config = config; }
|
||||
|
||||
get(type: string, obj, cdRef?: ChangeDetectorRef, existingPipe?: Pipe): Pipe {
|
||||
get(type: string, obj: any, cdRef?: ChangeDetectorRef, existingPipe?: Pipe): Pipe {
|
||||
if (isPresent(existingPipe) && existingPipe.supports(obj)) return existingPipe;
|
||||
|
||||
if (isPresent(existingPipe)) existingPipe.onDestroy();
|
||||
@ -67,7 +67,7 @@ export class Pipes {
|
||||
* })
|
||||
* ```
|
||||
*/
|
||||
static extend(config): Binding {
|
||||
static extend(config: StringMap<string, PipeFactory[]>): Binding {
|
||||
return new Binding(Pipes, {
|
||||
toFactory: (pipes: Pipes) => {
|
||||
if (isBlank(pipes)) {
|
||||
@ -82,7 +82,7 @@ export class Pipes {
|
||||
});
|
||||
}
|
||||
|
||||
static create(config, pipes: Pipes = null): Pipes {
|
||||
static create(config: StringMap<string, PipeFactory[]>, pipes: Pipes = null): Pipes {
|
||||
if (isPresent(pipes)) {
|
||||
StringMapWrapper.forEach(pipes.config, (v: PipeFactory[], k: string) => {
|
||||
if (StringMapWrapper.contains(config, k)) {
|
||||
|
@ -33,7 +33,7 @@ export class PromisePipe implements Pipe {
|
||||
|
||||
constructor(public _ref: ChangeDetectorRef) {}
|
||||
|
||||
supports(promise): boolean { return isPromise(promise); }
|
||||
supports(promise: any): boolean { return isPromise(promise); }
|
||||
|
||||
onDestroy(): void {
|
||||
if (isPresent(this._sourcePromise)) {
|
||||
@ -78,7 +78,7 @@ export class PromisePipe implements Pipe {
|
||||
*/
|
||||
@CONST()
|
||||
export class PromisePipeFactory implements PipeFactory {
|
||||
supports(promise): boolean { return isPromise(promise); }
|
||||
supports(promise: any): boolean { return isPromise(promise); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new PromisePipe(cdRef); }
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ import {ChangeDetectorRef} from '../change_detector_ref';
|
||||
export class UpperCasePipe implements Pipe {
|
||||
_latestValue: string = null;
|
||||
|
||||
supports(str): boolean { return isString(str); }
|
||||
supports(str: any): boolean { return isString(str); }
|
||||
|
||||
onDestroy(): void { this._latestValue = null; }
|
||||
|
||||
@ -41,7 +41,7 @@ export class UpperCasePipe implements Pipe {
|
||||
|
||||
@CONST()
|
||||
export class UpperCaseFactory implements PipeFactory {
|
||||
supports(str): boolean { return isString(str); }
|
||||
supports(str: any): boolean { return isString(str); }
|
||||
|
||||
create(cdRef: ChangeDetectorRef): Pipe { return new UpperCasePipe(); }
|
||||
}
|
||||
|
Reference in New Issue
Block a user