Re: computedStyle of cloneNode

Hi. Shane.

maybe this will be help you
https://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-OverrideAndComputed <https://www.w3.org/TR/2000/REC-DOM-Level-2-Style-20001113/css.html#CSS-OverrideAndComputed>

> Since a computed style is related to an Element node, if this element is removed from the document, the associated CSSStyleDeclaration and CSSValuerelated to this declaration are no longer valid.



> 2016. 5. 3., 오전 10:39, Shane Stephens <shans@google.com> 작성:
> 
> Hi list,
> 
> What should 
> getComputedStyle(foo.cloneNode(true)).opacity;

Here you clone node.
cloned node does not include in document.

> 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.
> 

so maybe getComputedStyle does not work.

> 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

Here is test codes :

http://jsbin.com/fofujoxovo/edit?html,js,console,output <http://jsbin.com/fofujoxovo/edit?html,js,console,output>
http://jsbin.com/hukigilolo/edit?html,js,console,output <http://jsbin.com/hukigilolo/edit?html,js,console,output>
http://jsbin.com/lirijafemu/edit?html,js,console,output <http://jsbin.com/lirijafemu/edit?html,js,console,output>

Thanks.

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