mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-10-07 12:33:47 +08:00
This updates Rollup, SVGO and clean-css. Only clean-css had reported breaking changes, but we are not affected (Node compatibility removals and changes to features we don't use). R=jacktfranklin@chromium.org Bug: none Change-Id: I94c293e128d1ddb81f12036421a715da210e7633 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/3060704 Commit-Queue: Tim van der Lippe <tvanderlippe@chromium.org> Reviewed-by: Paul Lewis <aerotwist@chromium.org>
35 lines
1006 B
JavaScript
35 lines
1006 B
JavaScript
var SUPPORTED_COMPACT_BLOCK_MATCHER = /^@media\W/;
|
|
var SUPPORTED_QUOTE_REMOVAL_MATCHER = /^@(?:keyframes|-moz-keyframes|-o-keyframes|-webkit-keyframes)\W/;
|
|
|
|
function tidyBlock(values, spaceAfterClosingBrace) {
|
|
var withoutSpaceAfterClosingBrace;
|
|
var withoutQuotes;
|
|
var i;
|
|
|
|
for (i = values.length - 1; i >= 0; i--) {
|
|
withoutSpaceAfterClosingBrace = !spaceAfterClosingBrace && SUPPORTED_COMPACT_BLOCK_MATCHER.test(values[i][1]);
|
|
withoutQuotes = SUPPORTED_QUOTE_REMOVAL_MATCHER.test(values[i][1]);
|
|
|
|
values[i][1] = values[i][1]
|
|
.replace(/\n|\r\n/g, ' ')
|
|
.replace(/\s+/g, ' ')
|
|
.replace(/(,|:|\() /g, '$1')
|
|
.replace(/ \)/g, ')');
|
|
|
|
if (withoutQuotes) {
|
|
values[i][1] = values[i][1]
|
|
.replace(/'([a-zA-Z][a-zA-Z\d\-_]+)'/, '$1')
|
|
.replace(/"([a-zA-Z][a-zA-Z\d\-_]+)"/, '$1');
|
|
}
|
|
|
|
if (withoutSpaceAfterClosingBrace) {
|
|
values[i][1] = values[i][1]
|
|
.replace(/\) /g, ')');
|
|
}
|
|
}
|
|
|
|
return values;
|
|
}
|
|
|
|
module.exports = tidyBlock;
|