Skip to content

Commit

Permalink
fix(Directive): Added ivy renderer support
Browse files Browse the repository at this point in the history
  • Loading branch information
kuuurt13 committed Jan 31, 2020
1 parent 30cbe7b commit 6d7a903
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions lib/directives/block-ui.directive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ export class BlockUIDirective implements OnInit {
ngOnInit() {
try {
this.viewRef.createEmbeddedView(this.templateRef);
const parentElement = this.viewRef.element.nativeElement.nextSibling;
const {
nextSibling,
previousSibling
} = this.viewRef.element.nativeElement;
const parentElement = nextSibling || previousSibling;

if (parentElement && !this.isComponentInTemplate(parentElement)) {
this.renderer.addClass(parentElement, 'block-ui__element');
Expand Down Expand Up @@ -82,8 +86,15 @@ export class BlockUIDirective implements OnInit {

// Needed for IE (#17)
private findContentNode(element: any) {
const { nextSibling } = element;
return [nextSibling, nextSibling.nextSibling].find((e) => e.localName === 'block-ui-content');
const nextSibling = element.nextSibling || {};
const previousSibling = element.previousSibling || {};

return [
nextSibling,
nextSibling.nextSibling,
previousSibling,
previousSibling.previousSibling
].find((e) => e && e.localName === 'block-ui-content');
}

private createComponent() {
Expand Down

0 comments on commit 6d7a903

Please sign in to comment.