Polymer uses `@apply` rule on property level, so we support it now too.
* Fixed issue [#612](https://github.com/jakubpawlowicz/clean-css/issues/612) - adds HTTP proxy support.
* Fixed issue [#625](https://github.com/jakubpawlowicz/clean-css/issues/625) - adds length unit optimizations.
* Fixed issue [#644](https://github.com/jakubpawlowicz/clean-css/issues/644) - adds time unit optimizations.
+* Fixed issue [#648](https://github.com/jakubpawlowicz/clean-css/issues/648) - adds property level at-rule support.
[3.3.9 / 2015-08-09](https://github.com/jakubpawlowicz/clean-css/compare/v3.3.8...v3.3.9)
==================
var stringifySelectors = require('../stringifier/one-time').selectors;
var stringifyValue = require('../stringifier/one-time').value;
+var AT_RULE = 'at-rule';
+
function extract(token) {
var properties = [];
if (property.indexOf('__ESCAPED') === 0)
continue;
+ if (property[0] == AT_RULE)
+ continue;
+
var name = token[2][i][0][0];
if (name.length === 0)
continue;
var lineBreak = require('os').EOL;
+var AT_RULE = 'at-rule';
+var PROPERTY_SEPARATOR = ';';
+
function hasMoreProperties(tokens, index) {
for (var i = index, l = tokens.length; i < l; i++) {
if (typeof tokens[i] != 'string')
if (typeof token == 'string') {
store(token, context);
+ } else if (token[0] == AT_RULE) {
+ propertyAtRule(token[1], isLast, context);
} else {
store(token[0], context);
store(':', context);
}
}
+function propertyAtRule(value, isLast, context) {
+ var store = context.store;
+
+ store(value, context);
+ if (!isLast)
+ store(PROPERTY_SEPARATOR, context);
+}
+
function value(tokens, position, isLast, context) {
var store = context.store;
var token = tokens[position];
if (j < m - 1 && (inFilter(token) || !inSpecialContext(token, j, context))) {
store(' ', context);
} else if (j == m - 1 && !isLast && hasMoreProperties(tokens, position + 1)) {
- store(';', context);
+ store(PROPERTY_SEPARATOR, context);
}
}
}
var COMMA = ',';
var FORWARD_SLASH = '/';
+var AT_RULE = 'at-rule';
+
function selectorName(value) {
return value[0];
}
var candidate = candidates[i];
var firstColonAt = candidate.indexOf(':');
+ var atRule = candidate[0] == '@';
+ if (atRule) {
+ context.track(candidate);
+ list.push([AT_RULE, candidate.trim()]);
+ continue;
+ }
+
if (firstColonAt == -1) {
context.track(candidate);
if (candidate.indexOf('__ESCAPED_COMMENT_SPECIAL') > -1)
]
}, { processImport: false, root: process.cwd(), relativeTo: process.cwd() })
)
+ .addBatch(
+ optimizerContext('body at-rules', {
+ 'single @apply': [
+ 'a{@apply(--rule)}',
+ 'a{@apply(--rule)}'
+ ],
+ 'multiple @apply': [
+ 'a{@apply(--rule1);@apply(--rule2)}',
+ 'a{@apply(--rule1);@apply(--rule2)}'
+ ],
+ 'multiple @apply with some styling': [
+ 'a{@apply(--rule1);@apply(--rule2);color:red;display:block}',
+ 'a{@apply(--rule1);@apply(--rule2);color:red;display:block}'
+ ]
+ })
+ )
.addBatch(
optimizerContext('duplicate selectors with disabled advanced processing', {
'of a duplicate selector': [
['selector', [['div:nth-child(2n):not(.test)']], []]
]
],
+ '@apply': [
+ 'a{@apply(--rule);}',
+ [
+ [
+ 'selector',
+ [['a']],
+ [['at-rule', '@apply(--rule)']]
+ ]
+ ]
+ ],
'media query': [
'@media (min-width:980px){}',
[