Skip to content

Commit

Permalink
fix: linting and aot errors
Browse files Browse the repository at this point in the history
  • Loading branch information
crisbeto committed Mar 29, 2017
1 parent 4aa1ae1 commit 1ef8835
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 29 deletions.
4 changes: 2 additions & 2 deletions src/demo-app/style/style-demo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Component, Renderer} from '@angular/core';
import {Component, Renderer2} from '@angular/core';
import {FocusOriginMonitor} from '@angular/material';


Expand All @@ -9,5 +9,5 @@ import {FocusOriginMonitor} from '@angular/material';
styleUrls: ['style-demo.css'],
})
export class StyleDemo {
constructor(public renderer: Renderer, public fom: FocusOriginMonitor) {}
constructor(public renderer: Renderer2, public fom: FocusOriginMonitor) {}
}
48 changes: 25 additions & 23 deletions src/lib/button-toggle/button-toggle.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,28 +259,29 @@ describe('MdButtonToggle', () => {
expect(groupInstance.selected.value).toBe(groupInstance.value);
});

it('should have the correct FormControl state initially and after interaction', fakeAsync(() => {
expect(groupNgModel.valid).toBe(true);
expect(groupNgModel.pristine).toBe(true);
expect(groupNgModel.touched).toBe(false);

buttonToggleInstances[1].checked = true;
fixture.detectChanges();
tick();

expect(groupNgModel.valid).toBe(true);
expect(groupNgModel.pristine).toBe(false);
expect(groupNgModel.touched).toBe(false);

let nativeRadioLabel = buttonToggleDebugElements[2].query(By.css('label')).nativeElement;
nativeRadioLabel.click();
fixture.detectChanges();
tick();

expect(groupNgModel.valid).toBe(true);
expect(groupNgModel.pristine).toBe(false);
expect(groupNgModel.touched).toBe(true);
}));
it('should have the correct FormControl state initially and after interaction',
fakeAsync(() => {
expect(groupNgModel.valid).toBe(true);
expect(groupNgModel.pristine).toBe(true);
expect(groupNgModel.touched).toBe(false);

buttonToggleInstances[1].checked = true;
fixture.detectChanges();
tick();

expect(groupNgModel.valid).toBe(true);
expect(groupNgModel.pristine).toBe(false);
expect(groupNgModel.touched).toBe(false);

let nativeRadioLabel = buttonToggleDebugElements[2].query(By.css('label')).nativeElement;
nativeRadioLabel.click();
fixture.detectChanges();
tick();

expect(groupNgModel.valid).toBe(true);
expect(groupNgModel.pristine).toBe(false);
expect(groupNgModel.touched).toBe(true);
}));

it('should update the ngModel value when selecting a button toggle', fakeAsync(() => {
buttonToggleInstances[1].checked = true;
Expand Down Expand Up @@ -341,7 +342,8 @@ describe('MdButtonToggle', () => {
let fixture = TestBed.createComponent(ButtonToggleGroupWithInitialValue);
let testComponent = fixture.debugElement.componentInstance;
let groupDebugElement = fixture.debugElement.query(By.directive(MdButtonToggleGroup));
let groupInstance: MdButtonToggleGroup = groupDebugElement.injector.get<MdButtonToggleGroup>(MdButtonToggleGroup);
let groupInstance: MdButtonToggleGroup = groupDebugElement.injector
.get<MdButtonToggleGroup>(MdButtonToggleGroup);

fixture.detectChanges();

Expand Down
10 changes: 6 additions & 4 deletions src/lib/core/style/focus-origin-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ export class FocusOriginMonitor {
* @returns An observable that emits when the focus state of the element changes.
* When the element is blurred, null will be emitted.
*/
monitor(element: HTMLElement, renderer: Renderer2, checkChildren: boolean): Observable<FocusOrigin> {
monitor(element: HTMLElement, renderer: Renderer2, checkChildren: boolean):
Observable<FocusOrigin> {

// Check if we're already monitoring this element.
if (this._elementInfo.has(element)) {
let info = this._elementInfo.get(element);
Expand Down Expand Up @@ -169,9 +171,9 @@ export class FocusOriginMonitor {
*/
private _setClasses(element: HTMLElement, origin: FocusOrigin): void {
let renderer = this._elementInfo.get(element).renderer;
let toggleClass = (_class: string, shouldSet: boolean) => {
shouldSet ? renderer.addClass(element, _class) : renderer.removeClass(element, _class);
}
let toggleClass = (className: string, shouldSet: boolean) => {
shouldSet ? renderer.addClass(element, className) : renderer.removeClass(element, className);
};

toggleClass('cdk-focused', !!origin);
toggleClass('cdk-touch-focused', origin === 'touch');
Expand Down

0 comments on commit 1ef8835

Please sign in to comment.