Skip to content

Commit c3127eb

Browse files
committed
Import regex should check for multiple whitespaces and semi-colon at end.
1 parent 010d436 commit c3127eb

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

scripts/ci/forbidden-identifiers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ const componentFolders = fs
4343
const scopePackages = ['src/core'].concat(componentFolders);
4444

4545
const blockedRegex = new RegExp(blocked_statements.join('|'), 'g');
46-
const importRegex = /from '(.*)'/g;
46+
const importRegex = /from\s+'(.*)';/g;
4747

4848
/**
4949
* Find the fork point between HEAD of the current branch, and master.

src/components/checkbox/checkbox.ts

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@ import {
88
Provider,
99
Renderer,
1010
ViewEncapsulation,
11-
forwardRef,
12-
AfterContentInit
11+
forwardRef
1312
} from '@angular/core';
14-
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/common';
13+
import {NG_VALUE_ACCESSOR, ControlValueAccessor} from '@angular/forms';
1514

1615
/**
1716
* Monotonically increasing integer used to auto-generate unique ids for checkbox components.
@@ -20,9 +19,9 @@ let nextId = 0;
2019

2120
/**
2221
* Provider Expression that allows md-checkbox to register as a ControlValueAccessor. This allows it
23-
* to support [(ngModel)] and ngControl.
22+
* to support [(ngModel)].
2423
*/
25-
const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR = new Provider(
24+
export const MD_CHECKBOX_CONTROL_VALUE_ACCESSOR = new Provider(
2625
NG_VALUE_ACCESSOR, {
2726
useExisting: forwardRef(() => MdCheckbox),
2827
multi: true
@@ -72,7 +71,7 @@ export class MdCheckboxChange {
7271
encapsulation: ViewEncapsulation.None,
7372
changeDetection: ChangeDetectionStrategy.OnPush
7473
})
75-
export class MdCheckbox implements AfterContentInit, ControlValueAccessor {
74+
export class MdCheckbox implements ControlValueAccessor {
7675
/**
7776
* Attached to the aria-label attribute of the host element. In most cases, arial-labelledby will
7877
* take precedence so this may be omitted.
@@ -116,9 +115,6 @@ export class MdCheckbox implements AfterContentInit, ControlValueAccessor {
116115
/** Called when the checkbox is blurred. Needed to properly implement ControlValueAccessor. */
117116
onTouched: () => any = () => {};
118117

119-
/** Whether the `checked` state has been set to its initial value. */
120-
private _isInitialized: boolean = false;
121-
122118
private _currentAnimationClass: string = '';
123119

124120
private _currentCheckState: TransitionCheckState = TransitionCheckState.Init;
@@ -147,19 +143,9 @@ export class MdCheckbox implements AfterContentInit, ControlValueAccessor {
147143
this._checked = checked;
148144
this._transitionCheckState(
149145
this._checked ? TransitionCheckState.Checked : TransitionCheckState.Unchecked);
150-
151-
// Only fire a change event if this isn't the first time the checked property is ever set.
152-
if (this._isInitialized) {
153-
this._emitChangeEvent();
154-
}
155146
}
156147
}
157148

158-
/** TODO: internal */
159-
ngAfterContentInit() {
160-
this._isInitialized = true;
161-
}
162-
163149
/**
164150
* Whether the checkbox is indeterminate. This is also known as "mixed" mode and can be used to
165151
* represent a checkbox with three states, e.g. a checkbox that represents a nested list of
@@ -275,6 +261,11 @@ export class MdCheckbox implements AfterContentInit, ControlValueAccessor {
275261

276262
if (!this.disabled) {
277263
this.toggle();
264+
265+
// Emit our custom change event if the native input emitted one.
266+
// It is important to only emit it, if the native input triggered one, because
267+
// we don't want to trigger a change event, when the `checked` variable changes for example.
268+
this._emitChangeEvent();
278269
}
279270
}
280271

0 commit comments

Comments
 (0)