Skip to content

refactor(grid-list): remove unnecessary coercion functions #12781

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/grid-list/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ng_module(
deps = [
"//src/lib/core",
"//src/cdk/bidi",
"//src/cdk/coercion",
],
tsconfig = "//src/lib:tsconfig-build.json",
)
Expand Down
23 changes: 0 additions & 23 deletions src/lib/grid-list/grid-list-measure.ts

This file was deleted.

11 changes: 4 additions & 7 deletions src/lib/grid-list/grid-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ import {MatGridTile} from './grid-tile';
import {TileCoordinator} from './tile-coordinator';
import {TileStyler, FitTileStyler, RatioTileStyler, FixedTileStyler} from './tile-styler';
import {Directionality} from '@angular/cdk/bidi';
import {
coerceToString,
coerceToNumber,
} from './grid-list-measure';
import {coerceNumberProperty} from '@angular/cdk/coercion';


// TODO(kara): Conditional (responsive) column count / row size.
Expand Down Expand Up @@ -72,17 +69,17 @@ export class MatGridList implements OnInit, AfterContentChecked {
/** Amount of columns in the grid list. */
@Input()
get cols(): number { return this._cols; }
set cols(value: number) { this._cols = coerceToNumber(value); }
set cols(value: number) { this._cols = Math.round(coerceNumberProperty(value)); }

/** Size of the grid list's gutter in pixels. */
@Input()
get gutterSize(): string { return this._gutter; }
set gutterSize(value: string) { this._gutter = coerceToString(value); }
set gutterSize(value: string) { this._gutter = `${value || ''}`; }

/** Set internal representation of row height from the user-provided value. */
@Input()
set rowHeight(value: string | number) {
const newValue = coerceToString(value);
const newValue = `${value || ''}`;

if (newValue !== this._rowHeight) {
this._rowHeight = newValue;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/grid-list/grid-tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
ChangeDetectionStrategy,
} from '@angular/core';
import {MatLine, MatLineSetter} from '@angular/material/core';
import {coerceToNumber} from './grid-list-measure';
import {coerceNumberProperty} from '@angular/cdk/coercion';

@Component({
moduleId: module.id,
Expand All @@ -41,12 +41,12 @@ export class MatGridTile {
/** Amount of rows that the grid tile takes up. */
@Input()
get rowspan(): number { return this._rowspan; }
set rowspan(value: number) { this._rowspan = coerceToNumber(value); }
set rowspan(value: number) { this._rowspan = Math.round(coerceNumberProperty(value)); }

/** Amount of columns that the grid tile takes up. */
@Input()
get colspan(): number { return this._colspan; }
set colspan(value: number) { this._colspan = coerceToNumber(value); }
set colspan(value: number) { this._colspan = Math.round(coerceNumberProperty(value)); }

/**
* Sets the style of the grid-tile element. Needs to be set manually to avoid
Expand Down