{"action":"created","issue":{"url":"https://api.github.com/repos/angular/angular/issues/2476","labels_url":"https://api.github.com/repos/angular/angular/issues/2476/labels{/name}","comments_url":"https://api.github.com/repos/angular/angular/issues/2476/comments","events_url":"https://api.github.com/repos/angular/angular/issues/2476/events","html_url":"https://github.com/angular/angular/issues/2476","id":87393753,"number":2476,"title":"Proposal: Promote direct use of `Renderer` and remove `ElementRef.domElement`","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},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-06-11T15:56:14Z","updated_at":"2015-06-11T16:08:41Z","closed_at":null,"body":"Right now, users can't really use the methods `Renderer.setElementProperty` or `Renderer.callAction` directly as these methods rely on the fact that the correct getters/setters/method calls have been registered during compilation. I.e. if a directive calls `Renderer.setElementProperty`, it needs to also have a `hostProperty` with the same name, as otherwise there is no setter registered.\r\n\r\nHowever, if we had a binding schema (#2014), we could automatically generate all valid getters/setters/method callers without looking at the actual bindings.\r\n\r\nGiven direct access to the `Renderer.setProperty` / `Renderer.callAction` makes sense, we can then remove `ElementRef.domElement`: \r\n\r\n1. store `ElementRef` as values of variable instead of the dom element (see #2461).\r\n2. When an AST action is evaluated, it could convert `elementRef.someProperty = ...` / `elementRef.focus()` into `renderer.setElementProperty(elementRef, 'someProperty')` / `renderer.callAction(elementRef, 'focus', [])`.\r\n\r\nWhere could this help?\r\n\r\n- See e.g. the `Class` directive, which could then add/remove classes via a call to `Renderer.setProperty` instead of using `ElementRef.domElement`\r\n- This would clean up the `ElementRef.domElement` hack, as this only works for the DOM and not for NativeScript / other renderers."},"comment":{"url":"https://api.github.com/repos/angular/angular/issues/comments/111187461","html_url":"https://github.com/angular/angular/issues/2476#issuecomment-111187461","issue_url":"https://api.github.com/repos/angular/angular/issues/2476","id":111187461,"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},"created_at":"2015-06-11T16:08:41Z","updated_at":"2015-06-11T16:08:41Z","body":"@mhevery @vsavkin Let's talk about this today..."}}