Angular directive for DOM removals fails

Issue #13685032 • Unassigned

Details

Author
Marko
Created
Sep 11, 2017
Privacy
This issue is public.
Found in
  • Microsoft Edge
Found in build #
40.15063
Reports
Reported by 1 person

Sign in to watch or report this issue.

Steps to reproduce

The following code runs fine in other browsers but fails in Edge when used on a component tag.

import { Directive, ElementRef } from '@angular/core’;

// remove the host of a component and render just the inner component html
@Directive({
selector: '[remove-host]'
})
export class RemoveHostDirective {
constructor(private el: ElementRef) {
}

// wait for the component to render completely
ngOnInit() {
    let nativeElement: HTMLElement = this.el.nativeElement,
        parentElement: HTMLElement = nativeElement.parentElement;
    // move all children out of the element
    while (nativeElement.firstChild) {
        parentElement.insertBefore(nativeElement.firstChild, nativeElement);
    }
    // remove the empty element(the host)
    parentElement.removeChild(nativeElement);
}

}

You can find more details about what this is about here
https://stackoverflow.com/questions/34280475/remove-the-host-html-element-selectors-created-by-angular-component

Attachments

0 attachments

    Comments and activity

    • This was actually a result of failed Modernizr load. So you can close this issue.

    You need to sign in to your Microsoft account to add a comment.

    Sign in