{"action":"created","comment":{"url":"https://api.github.com/repos/angular/angular/pulls/comments/29091773","id":29091773,"diff_hunk":"@@ -0,0 +1,177 @@\n+import {Injector, Injectable, Binding} from 'angular2/di';\n+import {ListWrapper, MapWrapper, Map, StringMapWrapper, List} from 'angular2/src/facade/collection';\n+import {isPresent, isBlank, BaseException} from 'angular2/src/facade/lang';\n+import * as viewModule from './view';\n+import {Renderer, ViewRef, ViewContainerRef} from 'angular2/src/render/api';\n+import {AppViewManagerUtils} from './view_manager_utils';\n+import {AppViewPool} from './view_pool';\n+\n+/**\n+ * Entry point for creating, moving views in the view hierarchy and destroying views.\n+ * This manager contains all recursion and delegates to helper methods\n+ * in AppViewManagerUtils and the Renderer, so unit tests get simpler.\n+ */\n+@Injectable()\n+export class AppViewManager {\n+  _viewPool:AppViewPool;\n+  _utils:AppViewManagerUtils;\n+  _renderer:Renderer;\n+\n+  constructor(viewPool:AppViewPool, utils:AppViewManagerUtils, renderer:Renderer) {\n+    this._renderer = renderer;\n+    this._viewPool = viewPool;\n+    this._utils = utils;\n+  }\n+\n+  createDynamicComponentView(hostView:viewModule.AppView, boundElementIndex:number,\n+      componentProtoView:viewModule.AppProtoView, componentBinding:Binding, injector:Injector):viewModule.AppView {\n+    var componentView = this._createView(componentProtoView);\n+    var renderViewRefs = this._renderer.createDynamicComponentView(hostView.render, boundElementIndex, componentProtoView.render);\n+    componentView.render = renderViewRefs[0];\n+    this._utils.attachComponentView(hostView, boundElementIndex, componentView);\n+    this._utils.hydrateDynamicComponentInElementInjector(hostView, boundElementIndex, componentBinding, injector);\n+    this._utils.hydrateComponentView(hostView, boundElementIndex);\n+\n+    this._viewHydrateRecurse(componentView, renderViewRefs, 1);\n+    return componentView;\n+  }\n+\n+  createInPlaceHostView(parentComponentHostView:viewModule.AppView, parentComponentBoundElementIndex:number,\n+      hostElementSelector, hostProtoView:viewModule.AppProtoView, injector:Injector):viewModule.AppView {\n+    var parentRenderViewRef = null;\n+    if (isPresent(parentComponentHostView)) {\n+      parentRenderViewRef = parentComponentHostView.componentChildViews[parentComponentBoundElementIndex].render;\n+    }\n+    var hostView = this._createView(hostProtoView);\n+    var renderViewRefs = this._renderer.createInPlaceHostView(parentRenderViewRef, hostElementSelector, hostView.proto.render);\n+    hostView.render = renderViewRefs[0];\n+    this._utils.attachAndHydrateInPlaceHostView(parentComponentHostView, parentComponentBoundElementIndex, hostView, injector);\n+    this._viewHydrateRecurse(hostView, renderViewRefs, 1);\n+    return hostView;\n+  }\n+\n+  destroyInPlaceHostView(parentComponentHostView:viewModule.AppView, parentComponentBoundElementIndex:number, hostView:viewModule.AppView) {\n+    var parentRenderViewRef = null;\n+    if (isPresent(parentComponentHostView)) {\n+      parentRenderViewRef = parentComponentHostView.componentChildViews[parentComponentBoundElementIndex].render;\n+    }\n+    var hostViewRenderRef = hostView.render;\n+    this._utils.dehydrateAndDetachInPlaceHostView(parentComponentHostView, parentComponentBoundElementIndex, hostView);\n+    this._viewDehydrateRecurse(hostView);\n+    this._renderer.destroyInPlaceHostView(parentRenderViewRef, hostViewRenderRef);\n+    this._destroyView(hostView);\n+  }\n+\n+  createViewInContainer(parentView:viewModule.AppView, boundElementIndex:number,\n+      atIndex:number, protoView:viewModule.AppProtoView, injector:Injector = null):viewModule.AppView {\n+    var view = this._createView(protoView);\n+    var renderViewRefs = this._renderer.createViewInContainer(this._getRenderViewContainerRef(parentView, boundElementIndex), atIndex, view.proto.render);\n+    view.render = renderViewRefs[0];\n+\n+    this._utils.attachViewInContainer(parentView, boundElementIndex, atIndex, view);\n+    this._utils.hydrateViewInContainer(parentView, boundElementIndex, atIndex, injector);\n+    this._viewHydrateRecurse(view, renderViewRefs, 1);\n+    return view;\n+  }\n+\n+  destroyViewInContainer(parentView:viewModule.AppView, boundElementIndex:number, atIndex:number) {\n+    var viewContainer = parentView.viewContainers[boundElementIndex];\n+    var view = viewContainer.views[atIndex];\n+    this._utils.dehydrateView(view);\n+    this._viewDehydrateRecurse(view);\n+    this._utils.detachViewInContainer(parentView, boundElementIndex, atIndex);\n+    this._renderer.destroyViewInContainer(this._getRenderViewContainerRef(parentView, boundElementIndex), atIndex);\n+    this._destroyView(view);\n+  }\n+\n+  attachViewInContainer(parentView:viewModule.AppView, boundElementIndex:number, atIndex:number, view:viewModule.AppView) {\n+    this._utils.attachViewInContainer(parentView, boundElementIndex, atIndex, view);\n+    this._renderer.attachViewInContainer(this._getRenderViewContainerRef(parentView, boundElementIndex), atIndex, view.render);\n+  }\n+\n+  detachViewInContainer(parentView:viewModule.AppView, boundElementIndex:number, atIndex:number):viewModule.AppView {\n+    var viewContainer = parentView.viewContainers[boundElementIndex];\n+    var view = viewContainer.views[atIndex];\n+    this._utils.detachViewInContainer(parentView, boundElementIndex, atIndex);\n+    this._renderer.detachViewInContainer(this._getRenderViewContainerRef(parentView, boundElementIndex), atIndex);\n+  }\n+\n+  _getRenderViewContainerRef(parentView:viewModule.AppView, boundElementIndex:number) {\n+    return new ViewContainerRef(parentView.render, boundElementIndex);\n+  }\n+\n+  _createView(protoView:viewModule.AppProtoView) {\n+    var view = this._viewPool.getView(protoView);\n+    if (isBlank(view)) {\n+      view = this._utils.createView(protoView, this);\n+      var binders = protoView.elementBinders;\n+      for (var binderIdx = 0; binderIdx < binders.length; binderIdx++) {\n+        var binder = binders[binderIdx];\n+        if (binder.hasStaticComponent()) {\n+          var childView = this._createView(binder.nestedProtoView);","path":"modules/angular2/src/core/compiler/view_manager.js","position":111,"original_position":111,"commit_id":"24aab87a51ee8dedaa7f4abfdcfa6445b3901d91","original_commit_id":"24aab87a51ee8dedaa7f4abfdcfa6445b3901d91","user":{"login":"rkirov","id":95713,"avatar_url":"https://avatars.githubusercontent.com/u/95713?v=3","gravatar_id":"","url":"https://api.github.com/users/rkirov","html_url":"https://github.com/rkirov","followers_url":"https://api.github.com/users/rkirov/followers","following_url":"https://api.github.com/users/rkirov/following{/other_user}","gists_url":"https://api.github.com/users/rkirov/gists{/gist_id}","starred_url":"https://api.github.com/users/rkirov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkirov/subscriptions","organizations_url":"https://api.github.com/users/rkirov/orgs","repos_url":"https://api.github.com/users/rkirov/repos","events_url":"https://api.github.com/users/rkirov/events{/privacy}","received_events_url":"https://api.github.com/users/rkirov/received_events","type":"User","site_admin":false},"body":"Shouldn't this be '_createViewRecurse' since it recurses here?\r\n","created_at":"2015-04-24T22:42:05Z","updated_at":"2015-04-24T22:42:05Z","html_url":"https://github.com/angular/angular/pull/1512#discussion_r29091773","pull_request_url":"https://api.github.com/repos/angular/angular/pulls/1512","_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/comments/29091773"},"html":{"href":"https://github.com/angular/angular/pull/1512#discussion_r29091773"},"pull_request":{"href":"https://api.github.com/repos/angular/angular/pulls/1512"}}},"pull_request":{"url":"https://api.github.com/repos/angular/angular/pulls/1512","id":33989936,"html_url":"https://github.com/angular/angular/pull/1512","diff_url":"https://github.com/angular/angular/pull/1512.diff","patch_url":"https://github.com/angular/angular/pull/1512.patch","issue_url":"https://api.github.com/repos/angular/angular/issues/1512","number":1512,"state":"open","locked":false,"title":"[WIP] refactor(view): introduce AppViewManager to consolidate logic","user":{"login":"tbosch","id":690815,"avatar_url":"https://avatars.githubusercontent.com/u/690815?v=3","gravatar_id":"","url":"https://api.github.com/users/tbosch","html_url":"https://github.com/tbosch","followers_url":"https://api.github.com/users/tbosch/followers","following_url":"https://api.github.com/users/tbosch/following{/other_user}","gists_url":"https://api.github.com/users/tbosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tbosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbosch/subscriptions","organizations_url":"https://api.github.com/users/tbosch/orgs","repos_url":"https://api.github.com/users/tbosch/repos","events_url":"https://api.github.com/users/tbosch/events{/privacy}","received_events_url":"https://api.github.com/users/tbosch/received_events","type":"User","site_admin":false},"body":"AppViewManager is the single entry point to changing the view hierarchy.\r\nIt is split between the manager itself which does coordination and\r\nhelper methods, so both are easily testable in isolation.\r\n\r\nPart of #1477 \r\n\r\nAfter this is done the same pattern should be applied to the render side as well!","created_at":"2015-04-23T19:49:17Z","updated_at":"2015-04-24T22:42:05Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1734556d1582d2a892a8a6fdf11c6dff5b05fd8","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/angular/angular/pulls/1512/commits","review_comments_url":"https://api.github.com/repos/angular/angular/pulls/1512/comments","review_comment_url":"https://api.github.com/repos/angular/angular/pulls/comments{/number}","comments_url":"https://api.github.com/repos/angular/angular/issues/1512/comments","statuses_url":"https://api.github.com/repos/angular/angular/statuses/24aab87a51ee8dedaa7f4abfdcfa6445b3901d91","head":{"label":"tbosch:app-viewmgr","ref":"app-viewmgr","sha":"24aab87a51ee8dedaa7f4abfdcfa6445b3901d91","user":{"login":"tbosch","id":690815,"avatar_url":"https://avatars.githubusercontent.com/u/690815?v=3","gravatar_id":"","url":"https://api.github.com/users/tbosch","html_url":"https://github.com/tbosch","followers_url":"https://api.github.com/users/tbosch/followers","following_url":"https://api.github.com/users/tbosch/following{/other_user}","gists_url":"https://api.github.com/users/tbosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tbosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbosch/subscriptions","organizations_url":"https://api.github.com/users/tbosch/orgs","repos_url":"https://api.github.com/users/tbosch/repos","events_url":"https://api.github.com/users/tbosch/events{/privacy}","received_events_url":"https://api.github.com/users/tbosch/received_events","type":"User","site_admin":false},"repo":{"id":24733374,"name":"angular","full_name":"tbosch/angular","owner":{"login":"tbosch","id":690815,"avatar_url":"https://avatars.githubusercontent.com/u/690815?v=3","gravatar_id":"","url":"https://api.github.com/users/tbosch","html_url":"https://github.com/tbosch","followers_url":"https://api.github.com/users/tbosch/followers","following_url":"https://api.github.com/users/tbosch/following{/other_user}","gists_url":"https://api.github.com/users/tbosch/gists{/gist_id}","starred_url":"https://api.github.com/users/tbosch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbosch/subscriptions","organizations_url":"https://api.github.com/users/tbosch/orgs","repos_url":"https://api.github.com/users/tbosch/repos","events_url":"https://api.github.com/users/tbosch/events{/privacy}","received_events_url":"https://api.github.com/users/tbosch/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tbosch/angular","description":"","fork":true,"url":"https://api.github.com/repos/tbosch/angular","forks_url":"https://api.github.com/repos/tbosch/angular/forks","keys_url":"https://api.github.com/repos/tbosch/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tbosch/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tbosch/angular/teams","hooks_url":"https://api.github.com/repos/tbosch/angular/hooks","issue_events_url":"https://api.github.com/repos/tbosch/angular/issues/events{/number}","events_url":"https://api.github.com/repos/tbosch/angular/events","assignees_url":"https://api.github.com/repos/tbosch/angular/assignees{/user}","branches_url":"https://api.github.com/repos/tbosch/angular/branches{/branch}","tags_url":"https://api.github.com/repos/tbosch/angular/tags","blobs_url":"https://api.github.com/repos/tbosch/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tbosch/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tbosch/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/tbosch/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tbosch/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/tbosch/angular/languages","stargazers_url":"https://api.github.com/repos/tbosch/angular/stargazers","contributors_url":"https://api.github.com/repos/tbosch/angular/contributors","subscribers_url":"https://api.github.com/repos/tbosch/angular/subscribers","subscription_url":"https://api.github.com/repos/tbosch/angular/subscription","commits_url":"https://api.github.com/repos/tbosch/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/tbosch/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/tbosch/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/tbosch/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/tbosch/angular/contents/{+path}","compare_url":"https://api.github.com/repos/tbosch/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tbosch/angular/merges","archive_url":"https://api.github.com/repos/tbosch/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tbosch/angular/downloads","issues_url":"https://api.github.com/repos/tbosch/angular/issues{/number}","pulls_url":"https://api.github.com/repos/tbosch/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/tbosch/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/tbosch/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tbosch/angular/labels{/name}","releases_url":"https://api.github.com/repos/tbosch/angular/releases{/id}","created_at":"2014-10-02T19:30:59Z","updated_at":"2014-12-02T00:39:58Z","pushed_at":"2015-04-24T21:55:08Z","git_url":"git://github.com/tbosch/angular.git","ssh_url":"git@github.com:tbosch/angular.git","clone_url":"https://github.com/tbosch/angular.git","svn_url":"https://github.com/tbosch/angular","homepage":null,"size":5504,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"angular:master","ref":"master","sha":"b5e350b18c4548594013acb8b8046ec91e39f73f","user":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"repo":{"id":24195339,"name":"angular","full_name":"angular/angular","owner":{"login":"angular","id":139426,"avatar_url":"https://avatars.githubusercontent.com/u/139426?v=3","gravatar_id":"","url":"https://api.github.com/users/angular","html_url":"https://github.com/angular","followers_url":"https://api.github.com/users/angular/followers","following_url":"https://api.github.com/users/angular/following{/other_user}","gists_url":"https://api.github.com/users/angular/gists{/gist_id}","starred_url":"https://api.github.com/users/angular/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/angular/subscriptions","organizations_url":"https://api.github.com/users/angular/orgs","repos_url":"https://api.github.com/users/angular/repos","events_url":"https://api.github.com/users/angular/events{/privacy}","received_events_url":"https://api.github.com/users/angular/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/angular/angular","description":"","fork":false,"url":"https://api.github.com/repos/angular/angular","forks_url":"https://api.github.com/repos/angular/angular/forks","keys_url":"https://api.github.com/repos/angular/angular/keys{/key_id}","collaborators_url":"https://api.github.com/repos/angular/angular/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/angular/angular/teams","hooks_url":"https://api.github.com/repos/angular/angular/hooks","issue_events_url":"https://api.github.com/repos/angular/angular/issues/events{/number}","events_url":"https://api.github.com/repos/angular/angular/events","assignees_url":"https://api.github.com/repos/angular/angular/assignees{/user}","branches_url":"https://api.github.com/repos/angular/angular/branches{/branch}","tags_url":"https://api.github.com/repos/angular/angular/tags","blobs_url":"https://api.github.com/repos/angular/angular/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/angular/angular/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/angular/angular/git/refs{/sha}","trees_url":"https://api.github.com/repos/angular/angular/git/trees{/sha}","statuses_url":"https://api.github.com/repos/angular/angular/statuses/{sha}","languages_url":"https://api.github.com/repos/angular/angular/languages","stargazers_url":"https://api.github.com/repos/angular/angular/stargazers","contributors_url":"https://api.github.com/repos/angular/angular/contributors","subscribers_url":"https://api.github.com/repos/angular/angular/subscribers","subscription_url":"https://api.github.com/repos/angular/angular/subscription","commits_url":"https://api.github.com/repos/angular/angular/commits{/sha}","git_commits_url":"https://api.github.com/repos/angular/angular/git/commits{/sha}","comments_url":"https://api.github.com/repos/angular/angular/comments{/number}","issue_comment_url":"https://api.github.com/repos/angular/angular/issues/comments{/number}","contents_url":"https://api.github.com/repos/angular/angular/contents/{+path}","compare_url":"https://api.github.com/repos/angular/angular/compare/{base}...{head}","merges_url":"https://api.github.com/repos/angular/angular/merges","archive_url":"https://api.github.com/repos/angular/angular/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/angular/angular/downloads","issues_url":"https://api.github.com/repos/angular/angular/issues{/number}","pulls_url":"https://api.github.com/repos/angular/angular/pulls{/number}","milestones_url":"https://api.github.com/repos/angular/angular/milestones{/number}","notifications_url":"https://api.github.com/repos/angular/angular/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/angular/angular/labels{/name}","releases_url":"https://api.github.com/repos/angular/angular/releases{/id}","created_at":"2014-09-18T16:12:01Z","updated_at":"2015-04-24T21:46:42Z","pushed_at":"2015-04-24T22:32:21Z","git_url":"git://github.com/angular/angular.git","ssh_url":"git@github.com:angular/angular.git","clone_url":"https://github.com/angular/angular.git","svn_url":"https://github.com/angular/angular","homepage":null,"size":20701,"stargazers_count":2687,"watchers_count":2687,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":674,"mirror_url":null,"open_issues_count":278,"forks":674,"open_issues":278,"watchers":2687,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/angular/angular/pulls/1512"},"html":{"href":"https://github.com/angular/angular/pull/1512"},"issue":{"href":"https://api.github.com/repos/angular/angular/issues/1512"},"comments":{"href":"https://api.github.com/repos/angular/angular/issues/1512/comments"},"review_comments":{"href":"https://api.github.com/repos/angular/angular/pulls/1512/comments"},"review_comment":{"href":"https://api.github.com/repos/angular/angular/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/angular/angular/pulls/1512/commits"},"statuses":{"href":"https://api.github.com/repos/angular/angular/statuses/24aab87a51ee8dedaa7f4abfdcfa6445b3901d91"}}}}