diff --git a/modules/angular2/src/core/compiler/view_factory.js b/modules/angular2/src/core/compiler/view_factory.js index 9d862dddd7..dd5612ed51 100644 --- a/modules/angular2/src/core/compiler/view_factory.js +++ b/modules/angular2/src/core/compiler/view_factory.js @@ -26,12 +26,8 @@ export class ViewFactory { getView(protoView:viewModule.AppProtoView):viewModule.AppView { var pooledViews = MapWrapper.get(this._pooledViewsPerProtoView, protoView); - if (isPresent(pooledViews)) { - var result = ListWrapper.removeLast(pooledViews); - if (pooledViews.length === 0) { - MapWrapper.delete(this._pooledViewsPerProtoView, protoView); - } - return result; + if (isPresent(pooledViews) && pooledViews.length > 0) { + return ListWrapper.removeLast(pooledViews); } return this._createView(protoView); } diff --git a/modules/angular2/src/render/dom/view/view_factory.js b/modules/angular2/src/render/dom/view/view_factory.js index b9bf86739a..6a6b9fce49 100644 --- a/modules/angular2/src/render/dom/view/view_factory.js +++ b/modules/angular2/src/render/dom/view/view_factory.js @@ -36,12 +36,8 @@ export class ViewFactory { getView(protoView:pvModule.RenderProtoView):viewModule.RenderView { var pooledViews = MapWrapper.get(this._pooledViewsPerProtoView, protoView); - if (isPresent(pooledViews)) { - var result = ListWrapper.removeLast(pooledViews); - if (pooledViews.length === 0) { - MapWrapper.delete(this._pooledViewsPerProtoView, protoView); - } - return result; + if (isPresent(pooledViews) && pooledViews.length > 0) { + return ListWrapper.removeLast(pooledViews); } return this._createView(protoView, null); } diff --git a/modules/angular2/test/core/compiler/view_factory_spec.js b/modules/angular2/test/core/compiler/view_factory_spec.js index 3c89b72af2..7bea67953c 100644 --- a/modules/angular2/test/core/compiler/view_factory_spec.js +++ b/modules/angular2/test/core/compiler/view_factory_spec.js @@ -66,10 +66,10 @@ export function main() { return binder; } - it('should create views', () => { + it('should create views without cache', () => { var pv = createProtoView(); var vf = createViewFactory({ - capacity: 1 + capacity: 0 }); expect(vf.getView(pv) instanceof AppView).toBe(true); }); diff --git a/modules/angular2/test/render/dom/integration_testbed.js b/modules/angular2/test/render/dom/integration_testbed.js index 33719997db..35e0a7a151 100644 --- a/modules/angular2/test/render/dom/integration_testbed.js +++ b/modules/angular2/test/render/dom/integration_testbed.js @@ -38,7 +38,7 @@ export class IntegrationTestbed { var compiler = new Compiler(new DefaultStepFactory(parser, shadowDomStrategy), new FakeTemplateLoader(urlResolver, urlData)); if (isBlank(viewCacheCapacity)) { - viewCacheCapacity = 1; + viewCacheCapacity = 0; } if (isBlank(urlData)) { urlData = MapWrapper.create(); diff --git a/modules/angular2/test/render/dom/view/view_factory_spec.js b/modules/angular2/test/render/dom/view/view_factory_spec.js index 8c15768b8e..af06801c73 100644 --- a/modules/angular2/test/render/dom/view/view_factory_spec.js +++ b/modules/angular2/test/render/dom/view/view_factory_spec.js @@ -61,10 +61,10 @@ export function main() { shadowDomStrategy = new SpyShadowDomStrategy(); }); - it('should create views', () => { + it('should create views without cache', () => { var pv = createProtoView(); var vf = createViewFactory({ - capacity: 1 + capacity: 0 }); expect(vf.getView(pv) instanceof RenderView).toBe(true); });