Browsers strip the whitespace before evaluating so should we.
* Fixed issue [#186](https://github.com/GoalSmashers/clean-css/issues/186) - strip unit from 0rem.
* Fixed issue [#207](https://github.com/GoalSmashers/clean-css/issues/207) - bug in parsing protocol `@import`s.
* Fixed issue [#213](https://github.com/GoalSmashers/clean-css/issues/213) - faster rgb to hex transforms.
+* Fixed issue [#217](https://github.com/GoalSmashers/clean-css/issues/217) - whitespace inside attribute selectors and urls.
* Fixed issue [#218](https://github.com/GoalSmashers/clean-css/issues/218) - `@import` statements cleanup.
* Fixed issue [#220](https://github.com/GoalSmashers/clean-css/issues/220) - selector between comments.
data = urlsProcessor.escape(data);
});
+ // whitespace inside attribute selectors brackets
+ replace(/\[([^\]]+)\]/g, function(match) {
+ return match.replace(/\s/g, '');
+ });
+
// line breaks
replace(/[\r]?\n/g, ' ');
},
restore: function(data) {
- return data.replace(urls.placeholderRegExp, urls.restore);
+ return data.replace(urls.placeholderRegExp, function(placeholder) {
+ return urls.restore(placeholder).replace(/\s/g, '');
+ });
}
};
};
".test[title='my_very_long_\
title']{display:block}",
".test[title=my_very_long_title]{display:block}"
+ ],
+ 'should strip whitespace between square brackets': [
+ 'body[ data-title ]{color:red}',
+ 'body[data-title]{color:red}'
+ ],
+ 'should strip whitespace inside square brackets': [
+ 'body[ data-title = x ]{color:red}',
+ 'body[data-title=x]{color:red}'
]
}),
'ie filters': cssContext({
'of an unknown file': [
"@import url(/fake.css);",
"@import url(/fake.css);"
+ ],
+ 'of an unknown file with extra whitespace': [
+ "@import url( /fake.css );",
+ "@import url(/fake.css);"
]
}, { processImport: false }),
'duplicate selectors with disabled advanced processing': cssContext({