Re: [csswg-drafts] [cssom] [css-display] [css-values] Clarify behavior of window.getComputedStyle on detached subtrees, and the definition of "the root element".

> Which document? The node document of the element passed to getComputedStyle, or the document the style is being computed in (that is, the document of the window which was the this for the getComputedStyle call)?

Err, sorry. I meant Stylo (Servo's style system). Servo itself apparently returns the empty string for disconnected nodes.

So in the following test-case, with `frame.html` being:

```html
<!doctype html>
<style>
  div { color: yellow }
</style>
```

and `test.html` being:

```html
<!doctype html>
<style>
:root { font-size: 100px; }
div { color: green; }
</style>
<iframe src="./frame.html"></iframe>
<script>
let iframe = document.querySelector('iframe');
iframe.onload = function() {
  let detached = document.createElement('div');
  alert(iframe.contentWindow.getComputedStyle(detached).color)
  alert(getComputedStyle(detached).color)
  document.body.appendChild(detached);
  document.body.offsetTop;
  alert(iframe.contentWindow.getComputedStyle(detached).color)
  alert(getComputedStyle(detached).color)
}
</script>
```

Both Gecko and Stylo behave the same way, resolving against the document associated with the window `getComputedStyle` was called on if the element is not connected, and otherwise returning the value in document the node is connected to. (This seems somewhat inconsistent, btw).

Not sure what does Edge do, I can't test it.

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

Received on Wednesday, 21 June 2017 22:58:27 UTC