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

> You'd simply point to the grid parent using any selector you want.

Let's say I want to add a new component on the Grid on a page that is built using something like CSS Modules, so class names for different components are generated dynamically and they have no IDs. I see that the component that defines the Grid is always the first `div` in the `body`, so I have to use `grid-item-of: body > div:first-child;` to put my component into that Grid. But then, at some point some other component dynamically inserts another `div` (e.g. a popup) _before_ this `div`. Oops, my selector suddenly becomes incorrect, so my component is no longer the Grid item. Also, what happens if there are several elements matching my selector, and all they define different Grids?

In the CSS Houdini terms, making the basic working prototype of the bare functionality of placing any element onto any existing Grid would require only [CSS Layout API](https://drafts.css-houdini.org/css-layout-api/) (to name the Grid, the existing Custom properties can be used). However, implementing the selector-referencing mechanism would require using CSS Parser API (which is still [in development](https://github.com/wicg/css-parser-api/)) to introduce the whole new type of CSS values as well (even [CSS Properties and Values API](https://drafts.css-houdini.org/css-properties-values-api/#supported-syntax-strings) doesn't seem to allow this yet).

So requiring this mechanism to rely on selectors seems to make the implementation harder. And I can't agree that using selectors is so much better for authors, too. So I'd prefer to have the functionality of placing any element onto any Grid and using selectors for this as two separate issues, to prevent the latter from hampering the former.

> If names are generally better then we should replace selectors with naming in CSS in all places

Selectors are great for what they are: to select _DOM elements._  They are not so great for non-DOM things belonging to the CSS box tree only (pseudo-elements are trying, but they are tricky and browsers always have problems with them).

One of the reasons why old Regions failed was probably their unnecessary coupling with DOM. And I don't want this proposal to end that way:(

> One main item we seem to agree on is that there could be a new property, and that it could be named `grid-item-of`

Yes! 👍 

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

Received on Wednesday, 16 May 2018 21:16:48 UTC