source: imaps-frontend/node_modules/clean-css/lib/optimizer/restore-from-optimizing.js

main
Last change on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 1.9 KB
Line 
1var Hack = require('./hack');
2
3var Marker = require('../tokenizer/marker');
4
5var ASTERISK_HACK = '*';
6var BACKSLASH_HACK = '\\';
7var IMPORTANT_TOKEN = '!important';
8var UNDERSCORE_HACK = '_';
9var BANG_HACK = '!ie';
10
11function restoreFromOptimizing(properties, restoreCallback) {
12 var property;
13 var restored;
14 var current;
15 var i;
16
17 for (i = properties.length - 1; i >= 0; i--) {
18 property = properties[i];
19
20 if (property.dynamic && property.important) {
21 restoreImportant(property);
22 continue;
23 }
24
25 if (property.dynamic) {
26 continue;
27 }
28
29 if (property.unused) {
30 continue;
31 }
32
33 if (!property.dirty && !property.important && !property.hack) {
34 continue;
35 }
36
37 if (property.optimizable && restoreCallback) {
38 restored = restoreCallback(property);
39 property.value = restored;
40 } else {
41 restored = property.value;
42 }
43
44 if (property.important) {
45 restoreImportant(property);
46 }
47
48 if (property.hack) {
49 restoreHack(property);
50 }
51
52 if ('all' in property) {
53 current = property.all[property.position];
54 current[1][1] = property.name;
55
56 current.splice(2, current.length - 1);
57 Array.prototype.push.apply(current, restored);
58 }
59 }
60}
61
62function restoreImportant(property) {
63 property.value[property.value.length - 1][1] += IMPORTANT_TOKEN;
64}
65
66function restoreHack(property) {
67 if (property.hack[0] == Hack.UNDERSCORE) {
68 property.name = UNDERSCORE_HACK + property.name;
69 } else if (property.hack[0] == Hack.ASTERISK) {
70 property.name = ASTERISK_HACK + property.name;
71 } else if (property.hack[0] == Hack.BACKSLASH) {
72 property.value[property.value.length - 1][1] += BACKSLASH_HACK + property.hack[1];
73 } else if (property.hack[0] == Hack.BANG) {
74 property.value[property.value.length - 1][1] += Marker.SPACE + BANG_HACK;
75 }
76}
77
78module.exports = restoreFromOptimizing;
Note: See TracBrowser for help on using the repository browser.