azaslavsky / domJSON

Convert DOM trees into compact JSON objects, and vice versa, as fast as possible.
http://azaslavsky.github.io/domJSON/
Other
126 stars 43 forks source link

Missing computedStyle in `toDOM` #19

Closed Hypercubed closed 6 years ago

Hypercubed commented 8 years ago

When using .toJSON with computedStyle: true computed styles are copied to the [node].style object. However, when using .toDOM only the [node].attributes.styles text is added to the element.

azaslavsky commented 8 years ago

Hmm, nice catch. I'll take a quick look this week and try to fix it.

azaslavsky commented 7 years ago

So I took a (very belated...) look, and this totally makes sense. The computed styles are pulled from two sources: the inline style, and the resolved CSS styles. The resolved styles aren't part of the DOM, so they are not reflected in the output. One solution to this could be to add a applyComputedStyles option to the .toDOM method.