Using renderer2 to access native element

671 Views Asked by At

Is there any difference in these two methods of accessing native element from security perspective?

SomeDirective implements OnInit{
  constructor(
    elementRef : ElementRef,
    renderer : Renderer2){}

 ngOnInit(){
  //method 1
  const el1 = this.elementRef.nativeElement;
  //method 2
  const el2 = this.renderer.GetRootElement(this.elementRef.nativeElement , true);
  //then use some method like this
  (el1 || el2).ScrollIntoView()
0

There are 0 best solutions below