You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[css-grid] Should grid-template-areas accept empty strings? #5110
There's in no non-rectangular named grid area (since there's no named grid area).
So it seems valid per the spec. But also pretty pointless, so possibly it was not deliberate. Given that neither Chromium nor old Edge support that, should we really allow it?
and if the grid is empty, you get a 50px tall and 0px wide grid. If you used grid-template-areas: "." you would get a 50x50 square. If you used grid-template-rows: 50px then you would have to reorder grid-auto-rows: 100px 50px in case there are two items, but this would also affect leading implicit tracks. Maybe grid-template-rows: 50px repeat(auto-fit, 100px) could be an alternative?
Anyways I don't know why somebody would want to do this, and allowing it for rows but not for columns is not much consistent either.
@fantasai I am struggling to think of a use case, so don't have a strong feeling either way, other than we should probably clarify it and raise the issue with the relevant browser.
It definitely wasn't deliberate, but there's also no use-case for it, so whatever's easiest to spec/implement seems reasonable. I have no preference one way or the other.
if the grid is empty, you get a 50px tall and 0px wide grid. If you used grid-template-areas: "." you would get a 50x50 square.
I'm a bit lost about why you think that should work like that. In your example if you have no items the grid container is 0x0 in Chromium/WebKit and 0x50 in Firefox (independently if you set grid-template-areas to "" or to "."). So it seems what you describe there is not happening in any browser right now.
Since nobody has a strong opinion either way, and nobody has use-cases for an explicitly empty g-t-a, I'm inclined to go with the majority implementation here, and rule that it's disallowed, so g-t-a must define at least one cell to be valid.
The CSS Working Group just discussed [css-grid] Should grid-template-areas accept empty strings?, and agreed to the following:
RESOLVED: grid-template-areas should not accept empty strings
The full IRC log of that discussion
<dael> Topic: [css-grid] Should grid-template-areas accept empty strings?
<dael> github: https://github.com//issues/5110
<dael> TabAtkins: Oriol raised issue that tech spec does not disallow empty strings in grid-template-areas
<dael> TabAtkins: No reason to do it either way but no one wants to put empty string in. Both Chrome and Edge consider it to be invalid
<dael> TabAtkins: As long as no objections we're going to say we require one cell to be expressed or it's invalid
<dael> Rossen_: Other opinions?
<dael> plinss: Req at least one cell with a name?
<dael> TabAtkins: A cell. It can be empty.
<dael> plinss: If you define an area with empty string for name what does it mean?
<dael> TabAtkins: It's got a track but no alignment
<dael> plinss: Same as dot?
<dael> florian: [missed] parser
<dael> TabAtkins: We don't give strings per cell name. String is name of all cells in row
<dael> plinss: Right
<florian> s/[missed] parser/no, empty string would be parse error/
<dael> oriol: Difference between empty stirng and string with dot is it forces it to have spec number of column and rows. If allow empty strings grid would force 5 rows and no column
<dael> oriol: Strings with dots you could have 1 column. That's difference
<dael> TabAtkins: Given no use case for rows with 0 columns and it doesn't go the other way around I'm inclined to call invalid matching Chrome and Edge
<dael> florian: Doesn't seem to be a use case to allow. It's a weird error and we can align on the market share of browsers
<dael> Rossen_: I can see it spit out by preprocessors or tools. Having spec is good
<dael> Rossen_: I don't hear obj or pushback.
<dael> Rossen_: Other questions or reasons why we shouldn't?
<florian> s/on the market share of browsers/, the market share of browsers who do this already prove it's possible/
<dael> dholbert: Sounds fine to me/Mozilla
<dael> RESOLVED: grid-template-areas should not accept empty strings
I don't feel strongly either way, so this seems fine to me. I'm assuming the resolution is not just about empty strings, but also that strings containing only whitespace are also invalid. IOW, a string that doesn't produce any null or named cell tokens is invalid.
Are all three invalid? (I think that would make sense, and it's how Mats has implemented the change in a pending patch, but I'm not sure it agrees with your "must define at least one cell" phrasing above... It sounds like your phrasing might allow the third example here.)
Ah, I see -- I suppose that third example does define one cell, but then fails a separate requirement about number of columns having to match between each string, so it still fails. Sounds good to me!
Activity
Loirooriol commentedon May 25, 2020
I guess the utility of this is something like
and if the grid is empty, you get a 50px tall and 0px wide grid. If you used
grid-template-areas: "."you would get a 50x50 square. If you usedgrid-template-rows: 50pxthen you would have to reordergrid-auto-rows: 100px 50pxin case there are two items, but this would also affect leading implicit tracks. Maybegrid-template-rows: 50px repeat(auto-fit, 100px)could be an alternative?Anyways I don't know why somebody would want to do this, and allowing it for rows but not for columns is not much consistent either.
fantasai commentedon May 25, 2020
CC @rachelandrew and @jensimmons for an opinion...
rachelandrew commentedon May 27, 2020
@fantasai I am struggling to think of a use case, so don't have a strong feeling either way, other than we should probably clarify it and raise the issue with the relevant browser.
tabatkins commentedon May 28, 2020
It definitely wasn't deliberate, but there's also no use-case for it, so whatever's easiest to spec/implement seems reasonable. I have no preference one way or the other.
Loirooriol commentedon May 28, 2020
Supporting this in Chromium would be simple (just removing some checks).
I'd be fine with that, though not a big fan of its asymmetry.
mrego commentedon May 29, 2020
I'm a bit lost about why you think that should work like that. In your example if you have no items the grid container is 0x0 in Chromium/WebKit and 0x50 in Firefox (independently if you set
grid-template-areasto""or to"."). So it seems what you describe there is not happening in any browser right now.Loirooriol commentedon May 29, 2020
@mrego See https://software.hixie.ch/utilities/js/live-dom-viewer/saved/8150
grid-template-areas: ""is 0x50 in Firefox and 0x0 in Chromium.grid-template-areas: "."is 50x50 everywhere, since it forces the explicit grid to have at least 1 column and 1 row, even if there is no item.tabatkins commentedon Jul 7, 2020
Since nobody has a strong opinion either way, and nobody has use-cases for an explicitly empty g-t-a, I'm inclined to go with the majority implementation here, and rule that it's disallowed, so g-t-a must define at least one cell to be valid.
@emilio @MatsPalmgren any objection to this?
css-meeting-bot commentedon Jul 15, 2020
The CSS Working Group just discussed
[css-grid] Should grid-template-areas accept empty strings?, and agreed to the following:RESOLVED: grid-template-areas should not accept empty stringsThe full IRC log of that discussion
<dael> Topic: [css-grid] Should grid-template-areas accept empty strings?<dael> github: https://github.com//issues/5110
<dael> TabAtkins: Oriol raised issue that tech spec does not disallow empty strings in grid-template-areas
<dael> TabAtkins: No reason to do it either way but no one wants to put empty string in. Both Chrome and Edge consider it to be invalid
<dael> TabAtkins: As long as no objections we're going to say we require one cell to be expressed or it's invalid
<dael> Rossen_: Other opinions?
<dael> plinss: Req at least one cell with a name?
<dael> TabAtkins: A cell. It can be empty.
<dael> plinss: If you define an area with empty string for name what does it mean?
<dael> TabAtkins: It's got a track but no alignment
<dael> plinss: Same as dot?
<dael> florian: [missed] parser
<dael> TabAtkins: We don't give strings per cell name. String is name of all cells in row
<dael> plinss: Right
<florian> s/[missed] parser/no, empty string would be parse error/
<dael> oriol: Difference between empty stirng and string with dot is it forces it to have spec number of column and rows. If allow empty strings grid would force 5 rows and no column
<dael> oriol: Strings with dots you could have 1 column. That's difference
<dael> TabAtkins: Given no use case for rows with 0 columns and it doesn't go the other way around I'm inclined to call invalid matching Chrome and Edge
<dael> florian: Doesn't seem to be a use case to allow. It's a weird error and we can align on the market share of browsers
<dael> Rossen_: I can see it spit out by preprocessors or tools. Having spec is good
<dael> Rossen_: I don't hear obj or pushback.
<dael> Rossen_: Other questions or reasons why we shouldn't?
<florian> s/on the market share of browsers/, the market share of browsers who do this already prove it's possible/
<dael> dholbert: Sounds fine to me/Mozilla
<dael> RESOLVED: grid-template-areas should not accept empty strings
MatsPalmgren commentedon Jul 16, 2020
I don't feel strongly either way, so this seems fine to me. I'm assuming the resolution is not just about empty strings, but also that strings containing only whitespace are also invalid. IOW, a string that doesn't produce any
nullornamedcell tokens is invalid.tabatkins commentedon Jul 17, 2020
Yes, it's actually a requirement that g-t-a must define at least one cell. This'll be clear when I make the edits.
dholbert commentedon Jul 21, 2020
@tabatkins : just to be sure we're understanding...
Can you clarify which of these values should be considered invalid:
Are all three invalid? (I think that would make sense, and it's how Mats has implemented the change in a pending patch, but I'm not sure it agrees with your "must define at least one cell" phrasing above... It sounds like your phrasing might allow the third example here.)
Loirooriol commentedon Jul 21, 2020
@dholbert The 3rd example must be invalid per
dholbert commentedon Jul 21, 2020
I like that, but I'm not sure it jives with Tab's "must define at least one cell" phrasing of the requirement.
dholbert commentedon Jul 21, 2020
Ah, I see -- I suppose that third example does define one cell, but then fails a separate requirement about number of columns having to match between each string, so it still fails. Sounds good to me!
tabatkins commentedon Jul 22, 2020
Correct.
[css-grid-1] Require grid-template-areas to define at least one grid …
tabatkins commentedon Jul 23, 2020
Tested by web-platform-tests/wpt@31bf745