diff --git a/modules/angular2/src/change_detection/pipes/keyvalue_changes.js b/modules/angular2/src/change_detection/pipes/keyvalue_changes.js index 0262b9a282..fa3d04e1f2 100644 --- a/modules/angular2/src/change_detection/pipes/keyvalue_changes.js +++ b/modules/angular2/src/change_detection/pipes/keyvalue_changes.js @@ -1,8 +1,19 @@ import {ListWrapper, MapWrapper, StringMapWrapper} from 'angular2/src/facade/collection'; - import {stringify, looseIdentical, isJsObject} from 'angular2/src/facade/lang'; -export class KeyValueChanges { +import {NO_CHANGE, Pipe} from './pipe'; + +export class KeyValueChangesFactory { + supports(obj):boolean { + return KeyValueChanges.supportsObj(obj); + } + + create():Pipe { + return new KeyValueChanges(); + } +} + +export class KeyValueChanges extends Pipe { _records:Map; _mapHead:KVChangeRecord; @@ -15,6 +26,7 @@ export class KeyValueChanges { _removalsTail:KVChangeRecord; constructor() { + super(); this._records = MapWrapper.create(); this._mapHead = null; this._previousMapHead = null; @@ -26,12 +38,20 @@ export class KeyValueChanges { this._removalsTail = null; } - static supports(obj):boolean { + static supportsObj(obj):boolean { return obj instanceof Map || isJsObject(obj); } - supportsObj(obj):boolean { - return KeyValueChanges.supports(obj); + supports(obj):boolean { + return KeyValueChanges.supportsObj(obj); + } + + transform(map){ + if (this.check(map)) { + return this; + } else { + return NO_CHANGE; + } } get isDirty():boolean { diff --git a/modules/angular2/test/change_detection/keyvalue_changes_spec.js b/modules/angular2/test/change_detection/keyvalue_changes_spec.js index 8bf5810513..321cbdf1f8 100644 --- a/modules/angular2/test/change_detection/keyvalue_changes_spec.js +++ b/modules/angular2/test/change_detection/keyvalue_changes_spec.js @@ -131,10 +131,10 @@ export function main() { if (isJsObject({})) { describe('JsObject changes', () => { it('should support JS Object', () => { - expect(KeyValueChanges.supports({})).toBeTruthy(); - expect(KeyValueChanges.supports("not supported")).toBeFalsy(); - expect(KeyValueChanges.supports(0)).toBeFalsy(); - expect(KeyValueChanges.supports(null)).toBeFalsy(); + expect(KeyValueChanges.supportsObj({})).toBeTruthy(); + expect(KeyValueChanges.supportsObj("not supported")).toBeFalsy(); + expect(KeyValueChanges.supportsObj(0)).toBeFalsy(); + expect(KeyValueChanges.supportsObj(null)).toBeFalsy(); }); it('should do basic object watching', () => {