tmpvar/jsdom — pull request #414 by papandreou (2012-03-02 00:09:21+00:00)
Title: Preserve the style attribute until node.style is touched

The `style` attribute of a node might legitimately contain multiple definitions of the same property, for instance:

Currently the value of the `style` attribute is immediately run through CSSOM, which by design (and per the spec) doesn't handle duplicate CSS properties, so in the above example, only the `-webkit-` definition would be left in `node.getAttribute('style')`.

I would like to be able to read the exact value of the `style` attribute, and for the document to serialize to the original contents. This is similar to https://github.com/NV/CSSOM/issues/16 for which I'm maintaining a workaround in a fork.

I'm suggesting a compromise where the `style` property behaves like in Firefox and Chrome:

var div = document.createElement('div');
div.setAttribute('style', 'color: black; color: white;')
div.getAttribute('style') // "color: black; color: white;"
div.style.backgroundColor = 'red'; // div.style gets populated here, "color: black;" is lost
div.getAttribute('style') // "color: white; background-color: red; "

(There's a minor difference, though: The attached code destroys the original `style` attribute when `node.style` is accessed, whereas Firefox and Chrome does leave it until node.style. is assigned to. As far as I can tell, we won't be able to mimic that without a CSSOM implementation that uses Harmony proxies or getters and setters for each supported CSS property).

What do you think?