1
0
mirror of https://github.com/svg/svgo.git synced 2025-07-31 07:44:22 +03:00

minifyStyles: preserve CDATA if needed

This commit is contained in:
GreLI
2016-03-08 20:35:00 +03:00
parent 5b88dc44dc
commit 215cd39c22
3 changed files with 22 additions and 3 deletions

View File

@ -43,10 +43,11 @@ exports.fn = function(item, svgoOptions) {
if(item.elem) {
if(item.isElem('style') && !item.isEmpty()) {
var styleCss = item.content[0].text || item.content[0].cdata || [];
var styleCss = item.content[0].text || item.content[0].cdata || [],
DATA = styleCss.indexOf('>') >= 0 || styleCss.indexOf('<') >= 0 ? 'cdata' : 'text';
if(styleCss.length > 0) {
var styleCssMinified = minifyCss(styleCss, svgoOptions);
item.content[0].text = styleCssMinified;
item.content[0][DATA] = styleCssMinified;
}
}