refactor(render): cleanup access to native dom elements

BREAKING CHANGES:
- rename `ElementRef.domElement` to `ElementRef.nativeElement`
- add `Renderer.getNativeElementSync` to make the app side
  less dependent on the dom renderer.
- don’t use `ElementRef.nativeElement` in directives but
  use the methods on `Renderer` directly.
- Removed `ElementRef.setAttribute`. Use `Renderer.setElementAttribute` instead.

Closes #2712
Last part of #2476
Closes #2476
This commit is contained in:
Tobias Bosch
2015-06-23 14:26:02 -07:00
parent 5c9e53a25e
commit c8bdacb195
24 changed files with 115 additions and 134 deletions

View File

@ -1,4 +1,4 @@
import {ElementRef, Component, Directive, View, Injectable} from 'angular2/angular2';
import {ElementRef, Component, Directive, View, Injectable, Renderer} from 'angular2/angular2';
// A service available to the Injector, used by the HelloCmp component.
@Injectable()
@ -12,7 +12,7 @@ class GreetingService {
class RedDec {
// ElementRef is always injectable and it wraps the element on which the
// directive was found by the compiler.
constructor(el: ElementRef) { el.domElement.style.color = 'red'; }
constructor(el: ElementRef, renderer: Renderer) { renderer.setElementStyle(el, 'color', 'red'); }
}
// Angular 2.0 supports 2 basic types of directives: