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

@ -62,7 +62,7 @@ export function main() {
tcb.createAsync(ChildComp).then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.domElement).toHaveText('Original Child');
expect(rootTestComponent.nativeElement).toHaveText('Original Child');
async.done();
});
}));
@ -72,11 +72,11 @@ export function main() {
tcb.createAsync(MyIfComp).then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.domElement).toHaveText('MyIf()');
expect(rootTestComponent.nativeElement).toHaveText('MyIf()');
rootTestComponent.componentInstance.showMore = true;
rootTestComponent.detectChanges();
expect(rootTestComponent.domElement).toHaveText('MyIf(More)');
expect(rootTestComponent.nativeElement).toHaveText('MyIf(More)');
async.done();
});
@ -89,7 +89,7 @@ export function main() {
.createAsync(MockChildComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.domElement).toHaveText('Mock');
expect(rootTestComponent.nativeElement).toHaveText('Mock');
async.done();
});
@ -103,7 +103,7 @@ export function main() {
.createAsync(ChildComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.domElement).toHaveText('Modified Child');
expect(rootTestComponent.nativeElement).toHaveText('Modified Child');
async.done();
});
@ -116,7 +116,7 @@ export function main() {
.createAsync(ParentComp)
.then((rootTestComponent) => {
rootTestComponent.detectChanges();
expect(rootTestComponent.domElement).toHaveText('Parent(Mock)');
expect(rootTestComponent.nativeElement).toHaveText('Parent(Mock)');
async.done();
});