IE’s cloneNode doesn’t actually clone!

When you want to deeply clone a node you use the cloneNode(true) method on the element you want to clone (see w3’s DOM Level 2 specifications)

IE Cant even clone

IE Cant even clone


Continue reading

Advertisements

Retrieving Inherited CSS Styles with DOM

If you need to get a CSS style from an element in a document, you cannot just test the style of the element directly. That is: Element.style.nameOfStyle won’t work. Take this example:

<p style="white-space:pre">
  Hello world - <b> A  B  C  D </b>
</p>

The immediate white space style of the bold element in the DOM will be normal (default for bold element). However the style is actually pre, since it inherits it from the paragraph ancestor element.
Continue reading