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:
@ -370,6 +370,12 @@ export class Renderer {
|
||||
*/
|
||||
dehydrateView(viewRef: RenderViewRef) {}
|
||||
|
||||
/**
|
||||
* Returns the native element at the given location.
|
||||
* Attention: In a WebWorker scenario, this should always return null!
|
||||
*/
|
||||
getNativeElementSync(location: RenderElementRef): any { return null; }
|
||||
|
||||
/**
|
||||
* Sets a property on an element.
|
||||
*/
|
||||
|
@ -53,6 +53,12 @@ export class DomRenderer extends Renderer {
|
||||
// noop for now
|
||||
}
|
||||
|
||||
getNativeElementSync(location: RenderElementRef) {
|
||||
return resolveInternalDomView(location.renderView)
|
||||
.boundElements[location.boundElementIndex]
|
||||
.element;
|
||||
}
|
||||
|
||||
attachComponentView(location: RenderElementRef, componentViewRef: RenderViewRef) {
|
||||
var hostView = resolveInternalDomView(location.renderView);
|
||||
var componentView = resolveInternalDomView(componentViewRef);
|
||||
|
Reference in New Issue
Block a user