autoprefixer icon indicating copy to clipboard operation
autoprefixer copied to clipboard

[css-grid] Autoprefixer outputting wrong IE grid-span syntax

Open dave-cross opened this issue 6 years ago • 6 comments
trafficstars

As mentioned in #1064, I'm seeing similar behaviour with span x not prefixing correctly with grid-gap.

When declaring grid-area: 1 / 2 / 1 / span 4;, it is being prefixed to the following:

    -ms-grid-row: 1;
    -ms-grid-column: 2;
    -ms-grid-column-span: 4;
    grid-area: 1 / 2 / 1 / span 4;

But -ms-grid-column-span: 4; should actually be -ms-grid-column-span: 7; to account for the grid gaps.

Test case: https://codepen.io/davecross/pen/ce7e08421ea29a8464ff82b84fcc7d12?editors=1100

dave-cross avatar Jan 18 '19 15:01 dave-cross

Here is a cleaner reduced test case of the problem:

Input CSS

.grid {
  display: grid;
}

.grid--2col {
  grid-gap: 20px;
  grid-template-columns: repeat(12, 1fr);
  grid-template-areas: "a a a a a a b b b b b b";
}

.grid--2col > .a {
  grid-area: a;
}

.grid--2col > .b {
  grid-area: b;
}

@media (min-width: 376px) {
  .grid--2col .smaller {
    grid-area: 1 / 2 / 1 / span 4;
  }
}

Current output CSS

.grid {
  display: -ms-grid;
  display: grid;
}

.grid--2col {
  grid-gap: 20px;
  -ms-grid-columns: 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr;
  grid-template-columns: repeat(12, 1fr);
      grid-template-areas: "a a a a a a b b b b b b";
}

.grid--2col > .a {
  -ms-grid-row: 1;
  -ms-grid-column: 1;
  -ms-grid-column-span: 11;
  grid-area: a;
}

.grid--2col > .b {
  -ms-grid-row: 1;
  -ms-grid-column: 13;
  -ms-grid-column-span: 11;
  grid-area: b;
}

@media (min-width: 376px) {
  .grid--2col .smaller {
    -ms-grid-row: 1;
    -ms-grid-column: 2;
    -ms-grid-column-span: 4;
    grid-area: 1 / 2 / 1 / span 4;
  }
}

expected output

.grid {
  display: -ms-grid;
  display: grid;
}

.grid--2col {
  grid-gap: 20px;
  -ms-grid-columns: 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr 20px 1fr;
  grid-template-columns: repeat(12, 1fr);
      grid-template-areas: "a a a a a a b b b b b b";
}

.grid--2col > .a {
  -ms-grid-row: 1;
  -ms-grid-column: 1;
  -ms-grid-column-span: 11;
  grid-area: a;
}

.grid--2col > .b {
  -ms-grid-row: 1;
  -ms-grid-column: 13;
  -ms-grid-column-span: 11;
  grid-area: b;
}

@media (min-width: 376px) {
  .grid--2col .smaller {
    -ms-grid-row: 1;
    -ms-grid-column: 2;
    -ms-grid-column-span: 7; /* <= Note the 7 here instead of 4 */
    grid-area: 1 / 2 / 1 / span 4;
  }
}

Dan503 avatar Sep 10 '19 12:09 Dan503

What's the status of this? @ai

burtek avatar Nov 26 '19 14:11 burtek

@burtek waiting for PR from someone

ai avatar Nov 26 '19 19:11 ai

@ai I'll try to understand how this works and maybe I'll be able to craft one, but don't take that for granted just yet

burtek avatar Nov 27 '19 02:11 burtek

You should check grid related files in lib/hacks. Sorry, I have no idea how to fix it exactly (need to work on different projects this week).

ai avatar Nov 27 '19 02:11 ai

Sorry, I have no idea how to fix it exactly (need to work on different projects this week).

I feel you, man.

Will give it a try in a few days

burtek avatar Nov 28 '19 14:11 burtek