1 | var mergeIntoShorthands = require('./merge-into-shorthands');
|
---|
2 | var overrideProperties = require('./override-properties');
|
---|
3 | var populateComponents = require('./populate-components');
|
---|
4 |
|
---|
5 | var restoreWithComponents = require('../restore-with-components');
|
---|
6 |
|
---|
7 | var wrapForOptimizing = require('../../wrap-for-optimizing').all;
|
---|
8 | var removeUnused = require('../../remove-unused');
|
---|
9 | var restoreFromOptimizing = require('../../restore-from-optimizing');
|
---|
10 |
|
---|
11 | var OptimizationLevel = require('../../../options/optimization-level').OptimizationLevel;
|
---|
12 |
|
---|
13 | function optimizeProperties(properties, withOverriding, withMerging, context) {
|
---|
14 | var levelOptions = context.options.level[OptimizationLevel.Two];
|
---|
15 | var _properties = wrapForOptimizing(properties, levelOptions.skipProperties);
|
---|
16 | var _property;
|
---|
17 | var i, l;
|
---|
18 |
|
---|
19 | populateComponents(_properties, context.validator, context.warnings);
|
---|
20 |
|
---|
21 | for (i = 0, l = _properties.length; i < l; i++) {
|
---|
22 | _property = _properties[i];
|
---|
23 | if (_property.block) {
|
---|
24 | optimizeProperties(_property.value[0][1], withOverriding, withMerging, context);
|
---|
25 | }
|
---|
26 | }
|
---|
27 |
|
---|
28 | if (withMerging && levelOptions.mergeIntoShorthands) {
|
---|
29 | mergeIntoShorthands(_properties, context.validator);
|
---|
30 | }
|
---|
31 |
|
---|
32 | if (withOverriding && levelOptions.overrideProperties) {
|
---|
33 | overrideProperties(_properties, withMerging, context.options.compatibility, context.validator);
|
---|
34 | }
|
---|
35 |
|
---|
36 | restoreFromOptimizing(_properties, restoreWithComponents);
|
---|
37 | removeUnused(_properties);
|
---|
38 | }
|
---|
39 |
|
---|
40 | module.exports = optimizeProperties;
|
---|