Browse Source

Minor fixes

pull/65/head
Sebastian Stehle 9 years ago
parent
commit
57e81055d7
  1. 16
      src/Squidex/app/framework/angular/cloak.directive.spec.ts
  2. 7
      src/Squidex/app/framework/angular/cloak.directive.ts

16
src/Squidex/app/framework/angular/cloak.directive.spec.ts

@ -12,16 +12,20 @@ describe('CloakDirective', () => {
let called = false;
const element = {
nativeElement: {
classList: {
remove: () => {
nativeElement: {}
};
const renderer = {
setElementClass: (target: any, className: string, isAdd: boolean) => {
called = true;
}
}
expect(target).toBe(element.nativeElement);
expect(className).toBe('sqx-cloak');
expect(isAdd).toBeFalsy();
}
};
new CloakDirective(element).ngOnInit();
new CloakDirective(<any>element, <any>renderer).ngOnInit();
expect(called).toBeTruthy();
});

7
src/Squidex/app/framework/angular/cloak.directive.ts

@ -5,18 +5,19 @@
* Copyright (c) Sebastian Stehle. All rights reserved
*/
import { Directive, ElementRef, OnInit } from '@angular/core';
import { Directive, ElementRef, OnInit, Renderer } from '@angular/core';
@Directive({
selector: '.sqx-cloak'
})
export class CloakDirective implements OnInit {
constructor(
private readonly element: ElementRef
private readonly element: ElementRef,
private readonly renderer: Renderer
) {
}
public ngOnInit() {
this.element.nativeElement.classList.remove('sqx-cloak');
this.renderer.setElementClass(this.element.nativeElement, 'sqx-cloak', false);
}
}
Loading…
Cancel
Save