juice icon indicating copy to clipboard operation
juice copied to clipboard

styleToAttribute and related functions do not apply for style attributes

Open tndev opened this issue 9 years ago • 2 comments

Is there a reason why juice not use the informations stored in the style attributes for:

  • applyHeightAttributes
  • applyWidthAttributes
  • styleToAttribute

e.g. <img style="width: 100px"> will remain <img style="width: 100px">.

But

<style>
img {
     width: 100px;
}
</style>
<img>

Will become <img style="width: 100px" width="100px">

Or have I overlooked an option there?

The reason I ask is because, when styling e.g. html emails using a WYSIWYG editor like CKEditor, then then most of the styles are applied using the style tag.

If this option does not exists right now then I would suggest to add it.

tndev avatar Dec 23 '16 10:12 tndev

The reason is that juice is conceived as a way to inline CSS into style tags, so it doesn't currently take any information from style tags and apply them elsewhere. It is a valid point though, so if someone wants to create a PR to update it that would be welcome.

jrit avatar Dec 24 '16 23:12 jrit

Where does it take the information from to change the CSS and add as HTML attribute?

I am trying to get a CSS background-color to bgcolor on a td?

HowardChris avatar Jun 05 '17 10:06 HowardChris