[csswg-drafts] Idea: Multiple Values for a Property (#9490)

AdamSobieski has just created a new issue for https://github.com/w3c/csswg-drafts:

== Idea: Multiple Values for a Property ==
Hello. I would like to propose an idea for CSS. As you are aware, historically, CSS properties could have one value and this value was determined utilizing an algorithm, [the cascade](https://developer.mozilla.org/en-US/docs/Web/CSS/Cascade).

What if a property could have multiple values aggregated together from multiple sources, like adding elements to a set?

Consider the following syntax
```css
div { prop: +x }
#el { prop: +y  }
.cls { prop: +z }
```
which hopes to communicate that
```html
<div id="el" class="cls" />
```
would have a set of values, `{x, y, z}`, for its property `prop`. It would obtain `x` from being a `div` element, `y` from having an id of `el`, and `z` from having a class of `cls`.

With respect to how to go about adding this functionality to CSS, we might look at and consider the CSSOM, specifically [CSSStyleDeclaration](https://drafts.csswg.org/cssom/#cssstyledeclaration) which provides the [getPropertyValue()](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue) method which returns a [`CSSOMString`](https://webidl.spec.whatwg.org/#idl-DOMString) value rather than an [`object`](https://webidl.spec.whatwg.org/#idl-object) (an `object` could be either a string or an array or list of strings). Perhaps a string representation of a set-based property's value returned by `getPropertyValue()` could be a delimited string of elements? Perhaps there could also be a `getPropertyValues()` function which would return an array or list of string-based values, this array or list having one element in it for single-value scenarios?

I hope that these ideas are of some interest to the group. What do you think of the capability for properties to have multiple values? Do any other syntax possibilities come to mind with which to express these ideas?

Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/9490 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 18 October 2023 09:41:22 UTC