Re: [csswg-drafts] [css-grid] Property "grid-item-of": display any element as part of any given grid

> I have to use grid-item-of: body > div:first-child;

No, you could use any type of selector, eg class names you mentioned.

> what happens if there are several elements matching my selector, and all they define different Grids?

When you apply the name, you're using a selector:
```
.foo .bar {
  display: grid;
  grid-name: the-grid;
}
```
Thus the issue you describe exists in both approaches.

As long as the name gets applied using a selector, all pros and cons of using selectors apply to both approaches.

> However, implementing the selector-referencing mechanism would require using CSS Parser API (which is still in development) to introduce the whole new type of CSS values as well (even CSS Properties and Values API doesn't seem to allow this yet).

Every CSS implementation supports selectors - they don't have to wait for Houdini.

> And I can't agree that using selectors is so much better for authors, too

Sure it's better not being required to write a line that's not necessary. Making up a name and declaring that name is not necessary because we can point to the element using eg a simple and short selector. It points to the element that is the grid. As long as elements can have only one grid that would work perfectly fine. (And `.foo .bar { display: grid; grid-name: the-grid; }` also supports just one grid per element as far as I can see.)

> One of the reasons why old Regions failed was probably their unnecessary coupling with DOM. 

Pointing to a grid elements using selectors doesn't require any specific HTML/DOM structure, and it doesn't require adding any markup, and it doesn't require any changes to the markup or the DOM.

I still would be OK with it if the CSS WG would require CSS users to create and declare and bind a name for each respective grid. (And I strongly suspect that that's what the CSS WG will do anyways).

-- 
GitHub Notification of comment by tobireif
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/2530#issuecomment-389786786 using your GitHub account

Received on Thursday, 17 May 2018 08:26:30 UTC