RE: computedStyle of cloneNode

Just a note. According to my tests, Gecko doesn't necessarily return the same styles for the cloned node.

For example, if you have `*{opacity:0.5}`, that will affect both the cloned element and the clone outside the document, so you will get 0.5 for both.

But if you have `body *{opacity:0.5}`, that will only affect the element inside the body, but not to the clone outside the document. So you will get 0.5 for the cloned and the initial 1 for the clone.

So I think in fact there are two different questions:

  - Should getComputedStyle work for elements outside the document?
  - Should selectors in stylesheet match elements outside the document?

-Oriol

From: shans@google.com
Date: Tue, 3 May 2016 01:39:56 +0000
To: www-style@w3.org
Subject: computedStyle of cloneNode

Hi list,
What should getComputedStyle(foo.cloneNode(true)).opacity;
be?
Gecko returns the same value as getComputedStyle(foo).opacity, while WebKit and Blink return empty strings. Edge returns "1" regardless of foo's opacity.
It seems to me that returning the computed style of the cloned node is wrong as the clone isn't in the document and therefore doesn't match the same rules as the original. However, I can't find any specification text that confirms this.
Thoughts?
Cheers,    -Shane 		 	   		  

Received on Tuesday, 3 May 2016 03:04:08 UTC