[csswg-drafts] [cssom] Throwing on invalid pseudo-elements in getComputedStyle is not web-compatible (#6501)

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

== [cssom] Throwing on invalid pseudo-elements in getComputedStyle is not web-compatible ==
I tried to implement the resolution from #2149 in Firefox, and we instantly [found](https://bugzilla.mozilla.org/show_bug.cgi?id=1724674) broken pages because of that.

There are two patterns that show up:

 * `getComputedStyle(something, "height");` (or any other property instead of `height`). Seems like a coding error on the given site, but all browsers agree on not throwing there.
 * `getComputedStyle(something, false);` (which per WebIDL rules gets turned into `getComputedStyle(something, "false");`). This is also an error (because the right thing to use if you want to be explicit about the argument is `null`, not `false`), but it seems throwing there is more harmful than good.

So I propose we need to at least not throw when the string doesn't start with a colon. All browsers agree on returning the non-pseudo-element style there, so I suggest to just spec reality there.

For the cases the string does start with a colon we could:

 * Try to throw (I can come back with data).
 * Not throw, returning the non-pseudo-element style instead (WebKit / Blink behavior): It is consistent with the "string doesn't begin with a colon" case, but it seems a bit unfortunate.
 * Not throw, returning an empty style (`length = 0`) (Firefox behavior).

I think I prefer the third but I'd love to hear opinions.

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


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

Received on Monday, 9 August 2021 09:45:48 UTC