[csswg-drafts] Idea: Properties with Object Values (#9502)

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

== Idea: Properties with Object Values ==
## Introduction

What if the value of a property could be an object?

## Syntax

Let us consider the following syntax with nested curly brackets:

```css
div { prop: { x: 123; y: 456 }; }
```

which intends to communicate that the element:

```xml
<div id="el" class="cls" />
```

would have a style property, `prop`, with a value that would be an object with properties. The expression `prop.x` would be equal to `123` and `prop.y` would be equal to `456`.

## Object Model

With respect to adding this functionality to CSS, we might want to consider the [`CSSStyleDeclaration`](https://drafts.csswg.org/cssom/#cssstyledeclaration) interface which provides the [`getPropertyValue()`](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertyvalue) method which is specified as returning a [`CSSOMString`](https://webidl.spec.whatwg.org/#idl-DOMString) value rather than an [`object`](https://webidl.spec.whatwg.org/#idl-object) value.

If `getPropertyValue()` returned an `object` value, then something like the following could work:

```js
var element = document.getElementById('el');
var prop = element.style.getPropertyValue('prop');

console.log(prop.x);
console.log(prop.y);
```

## Conclusion

I hope that these ideas are of some interest to the group. What do you think of the capability for properties to have complex objects for their 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/9502 using your GitHub account


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

Received on Friday, 20 October 2023 02:35:09 UTC