Skip to content

Commit d458690

Browse files
committed
Fix parsing of minimized css output
1 parent 34bf229 commit d458690

3 files changed

Lines changed: 19 additions & 7 deletions

File tree

‎src/lib/css-parse.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
_rx: {
172172
comments: /\/\*[^*]*\*+([^/*][^*]*\*+)*\//gim,
173173
port: /@import[^;]*;/gim,
174-
customProp: /(?:^|[\s;])--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
174+
customProp: /(?:^[^;\-\s}]+)?--[^;{]*?:[^{};]*?(?:[;\n]|$)/gim,
175175
mixinProp: /(?:^|[\s;])?--[^;{]*?:[^{;]*?{[^}]*?}(?:[;\n]|$)?/gim,
176176
mixinApply: /@apply[\s]*\([^)]*?\)[\s]*(?:[;\n]|$)?/gim,
177177
varApply: /[^;:]*?:[^;]*?var\([^;]*\)(?:[;\n]|$)?/gim,

‎test/unit/custom-style.html‎

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,9 @@
235235
--variable-property-after-property: 3px;
236236
--variable-property-after-assignment: 4px;
237237
--variable-property-before-assignment: 5px;
238+
--variable-into-first-variable: 9px;
239+
--variable-into-second-variable: 10px;
240+
--variable-into-third-variable: 11px;
238241
}
239242
</style>
240243
<child-variable-with-var id="child"></child-variable-with-var>
@@ -251,7 +254,8 @@
251254
--variable-between-properties: 6px;
252255
background-color: var(--variable-property-before-property); padding-top: var(--variable-property-after-property);
253256
--variable-assignment-before-property: 7px; padding-bottom: var(--variable-property-after-assignment);
254-
padding-left: var(--variable-property-before-assignment);--variable-assignment-after-property: 8px
257+
padding-left: var(--variable-property-before-assignment);--variable-assignment-after-property: 8px;
258+
top: 12px;--variable-from-other-variable: var(--variable-into-first-variable);--variable-from-another-variable: var(--variable-into-second-variable); --variable-from-last-variable: var(--variable-into-third-variable);
255259
}
256260
</style>
257261
<child-of-child-with-var id="child"></child-of-child-with-var>
@@ -266,6 +270,9 @@
266270
padding-right: var(--variable-between-properties);
267271
margin-left: var(--variable-assignment-before-property);
268272
margin-right: var(--variable-assignment-after-property);
273+
bottom: var(--variable-from-other-variable);
274+
left: var(--variable-from-another-variable);
275+
right: var(--variable-from-last-variable);
269276
}
270277
</style>
271278
Text
@@ -468,11 +475,16 @@
468475
assertComputed(el, '7px', 'margin-left');
469476
assertComputed(el, '8px', 'margin-right');
470477
assertComputed(el, 'rgb(255, 255, 0)', 'background-color');
478+
assertComputed(el, '9px', 'bottom');
479+
assertComputed(el, '10px', 'left');
480+
assertComputed(el, '11px', 'right');
481+
assertComputed(el, '12px', 'top');
471482

472483
// Because FireFox and Chrome parse font-family differently...
473484
var computed = getComputedStyle(el);
474485
assert.equal(computed['font-family'].replace(/['"]+/g, ''), 'Varela font');
475486
});
487+
476488
test('BEM-like CSS selectors under media queries', function() {
477489
assertComputed(document.querySelector('.foo--bar'), '3px');
478490
});

‎test/unit/styling-cross-scope-var.html‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
}
9595

9696
#gc4 {
97-
--grand-child-scope-var:
97+
--grand-child-scope-var:
9898
var(--gc4-scope);
9999
}
100100
</style>
@@ -286,7 +286,7 @@
286286
});
287287
</script>
288288
</dom-module>
289-
289+
290290
<dom-module id="x-scope">
291291
<style>
292292
:host {
@@ -439,14 +439,14 @@
439439
}
440440
</style>
441441
<template>
442-
442+
443443
</template>
444444
<script>
445445
HTMLImports.whenReady(function() {
446446
Polymer({
447447
is: 'x-inside'
448448
});
449-
});
449+
});
450450
</script>
451451
</dom-module>
452452

@@ -679,7 +679,7 @@
679679
// test('var values can be overridden by subsequent concrete properties', function() {
680680
// assertComputed(styled.$.overridesConcrete, '4px');
681681
// });
682-
682+
683683
});
684684

685685
</script>

0 commit comments

Comments
 (0)