Reputation: 57916
I found this awesome class that converts CSS style blocks to inline. However, I think it has a problem. For example, if you have the following:
<style type="text/css">
.myclass{
padding:0px;
}
<style>
<p class="myclass" style="padding-top: 40px;">Test</p>
It will convert the above to:
<p class="myclass" style="padding-top: 40px; padding:0px;">Test</p>
But the above is incorrect. It should prepend since the padding-top
inline has priority as it is already inline. So it should be:
<p class="myclass" style="padding:0px; padding-top: 40px;">Test</p>
But I am struggling where to make this edit in the class. I thought it would be straightforward and I could submit it to the class creator but I am struggling.
Any ideas?
Upvotes: 6
Views: 746
Reputation: 71
Should be fixed in the latest version: see https://github.com/tijsverkoyen/CssToInlineStyles
Upvotes: 0
Reputation: 4244
The best solution is create an issue and get in touch with the developer. So he can fix it for others too. That's a growth of the community .
Just going through the code in a quick way what I think is before building the chunks reverse the array $properties
$properties = array_reverse ( $properties, true );
// build chunks
foreach($properties as $key => $values)
The $properties = array_reverse ( $properties, true )
which preserves the key on the top of build chunks on line 318 as linked will reverse all.
Hope that helps! Not sure whether this will bring any other issues, just try.
Upvotes: 4
Reputation: 11
in my opinion
<p class="myclass" style="padding-top: 40px; padding:0px;">Test</p>
isn't wrong. because a inline-style overwrite a class-style
Upvotes: 0