Skip to content

Commit

Permalink
[css-grid] Fix bug when grid-rows/columns are prefixed with wrong val…
Browse files Browse the repository at this point in the history
…ues (#1149)

* [css-grid] Fix bug when grid-rows/columns are prefixed with wrong values

* [css-grid] Add test cases
  • Loading branch information
bogdan0083 authored and ai committed Oct 24, 2018
1 parent cac7636 commit c0eb6c6
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/hacks/grid-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,19 @@ function transformRepeat ({ nodes }, { gap }) {
count: []
})

// insert gap values
if (gap) {
size = size.filter(i => i.trim())
let val = []
for (let i = 1; i <= count; i++) {
if (gap && i > 1) {
val.push(gap)
}
val.push(size.join())
size.forEach((item, index) => {
if (index > 0 || i > 1) {
val.push(gap)
}
val.push(item)
})
}

return val.join(' ')
}

Expand Down
11 changes: 11 additions & 0 deletions test/cases/grid.css
Original file line number Diff line number Diff line change
Expand Up @@ -148,3 +148,14 @@
.place-self-b {
place-self: start end;
}

/* must have correct -ms-grid-rows/columns values */
.grid-correct-rows-columns {
display: grid;
grid-template-columns: 50px repeat(2, 1fr 2fr) 50px;
grid-template-rows: repeat(1, auto 100px);
grid-gap: 20px;
grid-template-areas:
". . . . . ."
". . . . . .";
}
11 changes: 11 additions & 0 deletions test/cases/grid.disabled.css
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,14 @@
.place-self-b {
place-self: start end;
}

/* must have correct -ms-grid-rows/columns values */
.grid-correct-rows-columns {
display: grid;
grid-template-columns: 50px repeat(2, 1fr 2fr) 50px;
grid-template-rows: repeat(1, auto 100px);
grid-gap: 20px;
grid-template-areas:
". . . . . ."
". . . . . .";
}
14 changes: 14 additions & 0 deletions test/cases/grid.out.css
Original file line number Diff line number Diff line change
Expand Up @@ -199,3 +199,17 @@
-ms-grid-column-align: end;
place-self: start end;
}

/* must have correct -ms-grid-rows/columns values */
.grid-correct-rows-columns {
display: -ms-grid;
display: grid;
-ms-grid-columns: 50px 20px 1fr 20px 2fr 20px 1fr 20px 2fr 20px 50px;
grid-template-columns: 50px repeat(2, 1fr 2fr) 50px;
-ms-grid-rows: auto 20px 100px;
grid-template-rows: repeat(1, auto 100px);
grid-gap: 20px;
grid-template-areas:
". . . . . ."
". . . . . .";
}

0 comments on commit c0eb6c6

Please sign in to comment.