File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -253,6 +253,18 @@ describe('MdGridList', () => {
253
253
let footer = fixture . debugElement . query ( By . directive ( MdGridTileText ) ) ;
254
254
expect ( footer . nativeElement . classList . contains ( 'mat-2-line' ) ) . toBe ( true ) ;
255
255
} ) ;
256
+
257
+ it ( 'should not use calc() that evaluates to 0' , ( ) => {
258
+ const fixture = TestBed . createComponent ( GirdListWithRowHeightRatio ) ;
259
+
260
+ fixture . componentInstance . heightRatio = '4:1' ;
261
+ fixture . detectChanges ( ) ;
262
+
263
+ const firstTile = fixture . debugElement . query ( By . directive ( MdGridTile ) ) . nativeElement ;
264
+
265
+ expect ( firstTile . style . marginTop ) . toBe ( '0px' ) ;
266
+ expect ( firstTile . style . left ) . toBe ( '0px' ) ;
267
+ } ) ;
256
268
} ) ;
257
269
258
270
Original file line number Diff line number Diff line change @@ -51,7 +51,7 @@ export abstract class TileStyler {
51
51
// edges, each tile only uses a fraction (gutterShare = numGutters / numCells) of the gutter
52
52
// size. (Imagine having one gutter per tile, and then breaking up the extra gutter on the
53
53
// edge evenly among the cells).
54
- return `(${ sizePercent } % - ( ${ this . _gutterSize } * ${ gutterFraction } ))` ;
54
+ return `(${ sizePercent } % - (${ this . _gutterSize } * ${ gutterFraction } ))` ;
55
55
}
56
56
57
57
@@ -64,7 +64,7 @@ export abstract class TileStyler {
64
64
getTilePosition ( baseSize : string , offset : number ) : string {
65
65
// The position comes the size of a 1x1 tile plus gutter for each previous tile in the
66
66
// row/column (offset).
67
- return calc ( `(${ baseSize } + ${ this . _gutterSize } ) * ${ offset } ` ) ;
67
+ return offset === 0 ? '0' : calc ( `(${ baseSize } + ${ this . _gutterSize } ) * ${ offset } ` ) ;
68
68
}
69
69
70
70
You can’t perform that action at this time.
0 commit comments