Skip to content

Commit

Permalink
fix(checkbox): fix pull request comments
Browse files Browse the repository at this point in the history
 * remove redundant css class
 * add JSDoc to hasLabel and change it from getter to function
  • Loading branch information
belev committed Apr 20, 2017
1 parent ab6e01a commit b5507cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/lib/checkbox/checkbox.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<label class="mat-checkbox-layout" #label>
<div class="mat-checkbox-inner-container"
[class.mat-checkbox-inner-container-no-side-margin]="!hasLabel">
[class.mat-checkbox-inner-container-no-side-margin]="!_hasLabel()">
<input #input
class="mat-checkbox-input cdk-visually-hidden" type="checkbox"
[id]="inputId"
Expand Down
17 changes: 5 additions & 12 deletions src/lib/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,12 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
right: auto;
}
}
}

&.mat-checkbox-inner-container-no-side-margin {
margin: {
left: 0;
right: 0;
}
.mat-checkbox-inner-container-no-side-margin {
margin: {
left: 0;
right: 0;
}
}

Expand Down Expand Up @@ -300,13 +300,6 @@ $_mat-checkbox-mark-stroke-size: 2 / 15 * $mat-checkbox-size !default;
right: $_mat-checkbox-item-spacing;
}
}

&.mat-checkbox-inner-container-no-side-margin {
margin: {
left: 0;
right: 0;
}
}
}
}

Expand Down
7 changes: 4 additions & 3 deletions src/lib/checkbox/checkbox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,10 @@ export class MdCheckbox implements ControlValueAccessor, AfterViewInit, OnDestro

@ViewChild('labelWrapper') _labelWrapper: ElementRef;

get hasLabel(): boolean {
const labelWrapperTextContent = this._labelWrapper.nativeElement.textContent;
return labelWrapperTextContent && labelWrapperTextContent.trim().length > 0;
/** Whether the checkbox has label */
_hasLabel(): boolean {
const labelText = this._labelWrapper.nativeElement.textContent || '';
return !!labelText.trim().length;
}

/**
Expand Down

0 comments on commit b5507cd

Please sign in to comment.