Re: [csswg-drafts] [cssom] Should shorthands in object from getComputedStyle be enumerable? (#2877)

It seems clear to me that `CSSStyleDeclaration` only contains longhands, e.g. [`setProperty`](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty) takes care of expanding shorthands. Then, `length` and `item()` should only account for longhands.

`item()` is an [indexed property getter](https://webidl.spec.whatwg.org/#dfn-indexed-property-getter), so per https://webidl.spec.whatwg.org/#es-iterable, `@@iterator` should just be `%Array.prototype.values%`.

So it follows that `[...getComputedStyle(document.body)]` should not include shorthands either.

Regarding enumeration:

```js
var arr = [];
for (let p in getComputedStyle(document.body)) arr.push(p);
arr;
```

https://webidl.spec.whatwg.org/#define-the-attributes says `[[Enumerable]]: true`, so regardless of whether they are longhands or shorthands, the above should include:
 - [camel-cased attributes](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-camel-cased-attribute) like `WebkitBorderRadius`
 - [webkit-cased attributes](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-webkit-cased-attribute) like `webkitBorderRadius`
 - [dashed attributes](https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-dashed-attribute) like `-webkit-border-radius`

That's the case in Gecko and WebKit, but Blink only enumerates `webkitBorderRadius`.

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


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

Received on Monday, 27 February 2023 14:46:57 UTC