less 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/less/js/.gitignore +7 -0
- data/lib/less/js/.npmignore +1 -0
- data/lib/less/js/CHANGELOG.md +118 -0
- data/lib/less/js/CONTRIBUTING.md +50 -0
- data/lib/less/js/Makefile +14 -2
- data/lib/less/js/bin/lessc +72 -21
- data/lib/less/js/dist/less-1.3.1.js +4011 -0
- data/lib/less/js/dist/less-1.3.1.min.js +9 -0
- data/lib/less/js/dist/less-1.3.2.js +4401 -0
- data/lib/less/js/dist/less-1.3.2.min.js +9 -0
- data/lib/less/js/dist/less-1.3.3.js +4413 -0
- data/lib/less/js/dist/less-1.3.3.min.js +9 -0
- data/lib/less/js/dist/less-rhino-1.3.1.js +3725 -0
- data/lib/less/js/dist/less-rhino-1.3.2.js +3990 -0
- data/lib/less/js/dist/less-rhino-1.3.3.js +4002 -0
- data/lib/less/js/lib/less/browser.js +192 -53
- data/lib/less/js/lib/less/colors.js +1 -0
- data/lib/less/js/lib/less/functions.js +159 -10
- data/lib/less/js/lib/less/index.js +124 -56
- data/lib/less/js/lib/less/lessc_helper.js +62 -0
- data/lib/less/js/lib/less/parser.js +352 -135
- data/lib/less/js/lib/less/rhino.js +84 -23
- data/lib/less/js/lib/less/tree.js +28 -0
- data/lib/less/js/lib/less/tree/anonymous.js +15 -1
- data/lib/less/js/lib/less/tree/assignment.js +3 -1
- data/lib/less/js/lib/less/tree/call.js +12 -6
- data/lib/less/js/lib/less/tree/color.js +10 -0
- data/lib/less/js/lib/less/tree/dimension.js +3 -1
- data/lib/less/js/lib/less/tree/directive.js +9 -5
- data/lib/less/js/lib/less/tree/element.js +8 -6
- data/lib/less/js/lib/less/tree/import.js +16 -13
- data/lib/less/js/lib/less/tree/media.js +16 -9
- data/lib/less/js/lib/less/tree/mixin.js +123 -46
- data/lib/less/js/lib/less/tree/operation.js +5 -0
- data/lib/less/js/lib/less/tree/quoted.js +15 -1
- data/lib/less/js/lib/less/tree/ratio.js +13 -0
- data/lib/less/js/lib/less/tree/rule.js +7 -0
- data/lib/less/js/lib/less/tree/ruleset.js +232 -34
- data/lib/less/js/lib/less/tree/selector.js +21 -11
- data/lib/less/js/lib/less/tree/unicode-descriptor.js +13 -0
- data/lib/less/js/lib/less/tree/url.js +16 -14
- data/lib/less/js/lib/less/tree/variable.js +13 -1
- data/lib/less/js/package.json +13 -3
- data/lib/less/js/test/browser-test-prepare.js +29 -0
- data/lib/less/js/test/browser/common.js +74 -0
- data/lib/less/js/test/browser/css/relative-urls/urls.css +36 -0
- data/lib/less/js/test/browser/css/rootpath-relative/urls.css +36 -0
- data/lib/less/js/test/browser/css/rootpath/urls.css +36 -0
- data/lib/less/js/test/browser/css/urls.css +36 -0
- data/lib/less/js/test/browser/jasmine-html.js +681 -0
- data/lib/less/js/test/browser/jasmine.css +82 -0
- data/lib/less/js/test/browser/jasmine.js +2600 -0
- data/lib/less/js/test/browser/less/imports/urls.less +4 -0
- data/lib/less/js/test/browser/less/imports/urls2.less +4 -0
- data/lib/less/js/test/browser/less/relative-urls/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath-relative/urls.less +33 -0
- data/lib/less/js/test/browser/less/rootpath/urls.less +33 -0
- data/lib/less/js/test/browser/less/urls.less +33 -0
- data/lib/less/js/test/browser/phantom-runner.js +139 -0
- data/lib/less/js/test/browser/runner-browser.js +3 -0
- data/lib/less/js/test/browser/runner-main.js +15 -0
- data/lib/less/js/test/browser/runner-relative-urls.js +4 -0
- data/lib/less/js/test/browser/runner-rootpath-relative.js +5 -0
- data/lib/less/js/test/browser/runner-rootpath.js +4 -0
- data/lib/less/js/test/browser/template.htm +10 -0
- data/lib/less/js/test/css/charsets.css +1 -0
- data/lib/less/js/test/css/colors.css +22 -0
- data/lib/less/js/test/css/comments.css +7 -0
- data/lib/less/js/test/css/css-3.css +57 -2
- data/lib/less/js/test/css/css-escapes.css +4 -0
- data/lib/less/js/test/css/css.css +11 -11
- data/lib/less/js/test/css/debug/linenumbers-all.css +43 -0
- data/lib/less/js/test/css/debug/linenumbers-comments.css +35 -0
- data/lib/less/js/test/css/debug/linenumbers-mediaquery.css +35 -0
- data/lib/less/js/test/css/functions.css +59 -2
- data/lib/less/js/test/css/ie-filters.css +7 -3
- data/lib/less/js/test/css/import-once.css +3 -0
- data/lib/less/js/test/css/import.css +7 -9
- data/lib/less/js/test/css/javascript.css +3 -2
- data/lib/less/js/test/css/media.css +116 -0
- data/lib/less/js/test/css/mixins-args.css +23 -4
- data/lib/less/js/test/css/mixins-guards.css +13 -0
- data/lib/less/js/test/css/mixins-important.css +21 -0
- data/lib/less/js/test/css/mixins-named-args.css +27 -0
- data/lib/less/js/test/css/mixins.css +50 -0
- data/lib/less/js/test/css/scope.css +20 -0
- data/lib/less/js/test/css/selectors.css +64 -0
- data/lib/less/js/test/css/static-urls/urls.css +42 -0
- data/lib/less/js/test/css/strings.css +2 -2
- data/lib/less/js/test/css/urls.css +42 -0
- data/lib/less/js/test/css/variables.css +0 -1
- data/lib/less/js/test/css/whitespace.css +4 -0
- data/lib/less/js/test/less-test.js +145 -36
- data/lib/less/js/test/less/charsets.less +3 -0
- data/lib/less/js/test/less/colors.less +27 -0
- data/lib/less/js/test/less/comments.less +12 -0
- data/lib/less/js/test/less/css-3.less +54 -6
- data/lib/less/js/test/less/css-escapes.less +6 -1
- data/lib/less/js/test/less/css.less +14 -12
- data/lib/less/js/test/less/debug/import/test.less +25 -0
- data/lib/less/js/test/less/debug/linenumbers.less +23 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.less +1 -0
- data/lib/less/js/test/less/errors/bad-variable-declaration1.txt +2 -0
- data/lib/less/js/test/less/errors/comment-in-selector.less +1 -0
- data/lib/less/js/test/less/errors/comment-in-selector.txt +2 -0
- data/lib/less/js/test/less/errors/import-missing.less +1 -0
- data/lib/less/js/test/less/errors/import-missing.txt +3 -0
- data/lib/less/js/test/less/errors/import-no-semi.less +1 -0
- data/lib/less/js/test/less/errors/import-no-semi.txt +2 -0
- data/lib/less/js/test/less/errors/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder1.txt +3 -0
- data/lib/less/js/test/less/errors/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/import-subfolder2.txt +2 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder1.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-subfolder2.less +1 -0
- data/lib/less/js/test/less/errors/imports/import-test.less +4 -0
- data/lib/less/js/test/less/errors/imports/subfolder/mixin-not-defined.less +1 -0
- data/lib/less/js/test/less/errors/imports/subfolder/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/javascript-error.less +3 -0
- data/lib/less/js/test/less/errors/javascript-error.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-1.txt +4 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.less +6 -0
- data/lib/less/js/test/less/errors/mixed-mixin-definition-args-2.txt +4 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.less +11 -0
- data/lib/less/js/test/less/errors/mixin-not-defined.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched.txt +3 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.less +6 -0
- data/lib/less/js/test/less/errors/mixin-not-matched2.txt +3 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.less +1 -0
- data/lib/less/js/test/less/errors/parse-error-curly-bracket.txt +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.less +2 -0
- data/lib/less/js/test/less/errors/parse-error-missing-bracket.txt +2 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.less +13 -0
- data/lib/less/js/test/less/errors/parse-error-with-import.txt +4 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.less +3 -0
- data/lib/less/js/test/less/errors/property-ie5-hack.txt +4 -0
- data/lib/less/js/test/less/errors/recursive-variable.less +1 -0
- data/lib/less/js/test/less/errors/recursive-variable.txt +2 -0
- data/lib/less/js/test/less/functions.less +64 -2
- data/lib/less/js/test/less/ie-filters.less +7 -0
- data/lib/less/js/test/less/import-once.less +4 -0
- data/lib/less/js/test/less/import.less +2 -1
- data/lib/less/js/test/less/import/deeper/import-once-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-and-relative-paths-test.less +6 -0
- data/lib/less/js/test/less/import/import-charset-test.less +1 -0
- data/lib/less/js/test/less/import/import-once-test-c.less +6 -0
- data/lib/less/js/test/less/import/import-test-a.less +1 -0
- data/lib/less/js/test/less/import/import-test-c.less +0 -1
- data/lib/less/js/test/less/import/imports/font.less +8 -0
- data/lib/less/js/test/less/import/imports/logo.less +5 -0
- data/lib/less/js/test/less/import/urls.less +1 -0
- data/lib/less/js/test/less/javascript.less +4 -2
- data/lib/less/js/test/less/media.less +120 -0
- data/lib/less/js/test/less/mixins-args.less +40 -10
- data/lib/less/js/test/less/mixins-guards.less +30 -0
- data/lib/less/js/test/less/mixins-important.less +4 -0
- data/lib/less/js/test/less/mixins-named-args.less +36 -0
- data/lib/less/js/test/less/mixins.less +47 -0
- data/lib/less/js/test/less/scope.less +48 -1
- data/lib/less/js/test/less/selectors.less +81 -0
- data/lib/less/js/test/less/static-urls/urls.less +33 -0
- data/lib/less/js/test/less/strings.less +1 -1
- data/lib/less/js/test/less/urls.less +33 -0
- data/lib/less/js/test/less/variables.less +0 -1
- data/lib/less/js/test/less/whitespace.less +7 -0
- data/lib/less/version.rb +1 -1
- metadata +101 -4
- data/lib/less/js/CHANGELOG +0 -41
- data/lib/less/js/lib/less/cssmin.js +0 -355
data/lib/less/js/CHANGELOG
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
1.3.0
|
2
|
-
|
3
|
-
@media bubbling
|
4
|
-
Support arbitrary entities as selectors
|
5
|
-
Variadic argument support, see: https://gist.github.com/1933613
|
6
|
-
Behaviour of zero-arity mixins has changed, see link above.
|
7
|
-
Allow '@import' directives in any selector
|
8
|
-
Media-query features can now be a variable
|
9
|
-
Automatic merging of media-query conditions
|
10
|
-
Fix global variable leaks
|
11
|
-
Fix error message on wrong-arity call
|
12
|
-
Fix an '@arguments' behaviour bug
|
13
|
-
Fix '::' selector output
|
14
|
-
Fix a bug when using @media with mixins
|
15
|
-
|
16
|
-
1.2.1
|
17
|
-
|
18
|
-
Fix imports on browser
|
19
|
-
Improve error reporting on browser
|
20
|
-
Fix Runtime error reports from imported files
|
21
|
-
Fix 'File not found' import error reporting
|
22
|
-
|
23
|
-
1.2.0
|
24
|
-
|
25
|
-
Mixin guards
|
26
|
-
New function `percentage`
|
27
|
-
New `color` function to parse hex color strings
|
28
|
-
New type-checking stylesheet functions
|
29
|
-
Fix Rhino support
|
30
|
-
Fix bug in string arguments to mixin call
|
31
|
-
Fix error reporting when index is 0
|
32
|
-
Fix browser support in webkit and IE
|
33
|
-
Fix string interpolation bug when var is empty
|
34
|
-
Support '!important' after mixin calls
|
35
|
-
Support vanilla @keyframes directive
|
36
|
-
Support variables in certain css selectors, like 'nth-child'
|
37
|
-
Support @media and @import features properly
|
38
|
-
Improve @import support with media features
|
39
|
-
Improve error reports from imported files
|
40
|
-
Improve function call error reporting
|
41
|
-
Improve error-reporting
|
@@ -1,355 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* cssmin.js
|
3
|
-
* Author: Stoyan Stefanov - http://phpied.com/
|
4
|
-
* This is a JavaScript port of the CSS minification tool
|
5
|
-
* distributed with YUICompressor, itself a port
|
6
|
-
* of the cssmin utility by Isaac Schlueter - http://foohack.com/
|
7
|
-
* Permission is hereby granted to use the JavaScript version under the same
|
8
|
-
* conditions as the YUICompressor (original YUICompressor note below).
|
9
|
-
*/
|
10
|
-
|
11
|
-
/*
|
12
|
-
* YUI Compressor
|
13
|
-
* http://developer.yahoo.com/yui/compressor/
|
14
|
-
* Author: Julien Lecomte - http://www.julienlecomte.net/
|
15
|
-
* Copyright (c) 2011 Yahoo! Inc. All rights reserved.
|
16
|
-
* The copyrights embodied in the content of this file are licensed
|
17
|
-
* by Yahoo! Inc. under the BSD (revised) open source license.
|
18
|
-
*/
|
19
|
-
var YAHOO = YAHOO || {};
|
20
|
-
YAHOO.compressor = YAHOO.compressor || {};
|
21
|
-
|
22
|
-
/**
|
23
|
-
* Utility method to replace all data urls with tokens before we start
|
24
|
-
* compressing, to avoid performance issues running some of the subsequent
|
25
|
-
* regexes against large strings chunks.
|
26
|
-
*
|
27
|
-
* @private
|
28
|
-
* @method _extractDataUrls
|
29
|
-
* @param {String} css The input css
|
30
|
-
* @param {Array} The global array of tokens to preserve
|
31
|
-
* @returns String The processed css
|
32
|
-
*/
|
33
|
-
YAHOO.compressor._extractDataUrls = function (css, preservedTokens) {
|
34
|
-
|
35
|
-
// Leave data urls alone to increase parse performance.
|
36
|
-
var maxIndex = css.length - 1,
|
37
|
-
appendIndex = 0,
|
38
|
-
startIndex,
|
39
|
-
endIndex,
|
40
|
-
terminator,
|
41
|
-
foundTerminator,
|
42
|
-
sb = [],
|
43
|
-
m,
|
44
|
-
preserver,
|
45
|
-
token,
|
46
|
-
pattern = /url\(\s*(["']?)data\:/g;
|
47
|
-
|
48
|
-
// Since we need to account for non-base64 data urls, we need to handle
|
49
|
-
// ' and ) being part of the data string. Hence switching to indexOf,
|
50
|
-
// to determine whether or not we have matching string terminators and
|
51
|
-
// handling sb appends directly, instead of using matcher.append* methods.
|
52
|
-
|
53
|
-
while ((m = pattern.exec(css)) !== null) {
|
54
|
-
|
55
|
-
startIndex = m.index + 4; // "url(".length()
|
56
|
-
terminator = m[1]; // ', " or empty (not quoted)
|
57
|
-
|
58
|
-
if (terminator.length === 0) {
|
59
|
-
terminator = ")";
|
60
|
-
}
|
61
|
-
|
62
|
-
foundTerminator = false;
|
63
|
-
|
64
|
-
endIndex = pattern.lastIndex - 1;
|
65
|
-
|
66
|
-
while(foundTerminator === false && endIndex+1 <= maxIndex) {
|
67
|
-
endIndex = css.indexOf(terminator, endIndex + 1);
|
68
|
-
|
69
|
-
// endIndex == 0 doesn't really apply here
|
70
|
-
if ((endIndex > 0) && (css.charAt(endIndex - 1) !== '\\')) {
|
71
|
-
foundTerminator = true;
|
72
|
-
if (")" != terminator) {
|
73
|
-
endIndex = css.indexOf(")", endIndex);
|
74
|
-
}
|
75
|
-
}
|
76
|
-
}
|
77
|
-
|
78
|
-
// Enough searching, start moving stuff over to the buffer
|
79
|
-
sb.push(css.substring(appendIndex, m.index));
|
80
|
-
|
81
|
-
if (foundTerminator) {
|
82
|
-
token = css.substring(startIndex, endIndex);
|
83
|
-
token = token.replace(/\s+/g, "");
|
84
|
-
preservedTokens.push(token);
|
85
|
-
|
86
|
-
preserver = "url(___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___)";
|
87
|
-
sb.push(preserver);
|
88
|
-
|
89
|
-
appendIndex = endIndex + 1;
|
90
|
-
} else {
|
91
|
-
// No end terminator found, re-add the whole match. Should we throw/warn here?
|
92
|
-
sb.push(css.substring(m.index, pattern.lastIndex));
|
93
|
-
appendIndex = pattern.lastIndex;
|
94
|
-
}
|
95
|
-
}
|
96
|
-
|
97
|
-
sb.push(css.substring(appendIndex));
|
98
|
-
|
99
|
-
return sb.join("");
|
100
|
-
};
|
101
|
-
|
102
|
-
/**
|
103
|
-
* Utility method to compress hex color values of the form #AABBCC to #ABC.
|
104
|
-
*
|
105
|
-
* DOES NOT compress CSS ID selectors which match the above pattern (which would break things).
|
106
|
-
* e.g. #AddressForm { ... }
|
107
|
-
*
|
108
|
-
* DOES NOT compress IE filters, which have hex color values (which would break things).
|
109
|
-
* e.g. filter: chroma(color="#FFFFFF");
|
110
|
-
*
|
111
|
-
* DOES NOT compress invalid hex values.
|
112
|
-
* e.g. background-color: #aabbccdd
|
113
|
-
*
|
114
|
-
* @private
|
115
|
-
* @method _compressHexColors
|
116
|
-
* @param {String} css The input css
|
117
|
-
* @returns String The processed css
|
118
|
-
*/
|
119
|
-
YAHOO.compressor._compressHexColors = function(css) {
|
120
|
-
|
121
|
-
// Look for hex colors inside { ... } (to avoid IDs) and which don't have a =, or a " in front of them (to avoid filters)
|
122
|
-
var pattern = /(\=\s*?["']?)?#([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])([0-9a-f])(\}|[^0-9a-f{][^{]*?\})/gi,
|
123
|
-
m,
|
124
|
-
index = 0,
|
125
|
-
isFilter,
|
126
|
-
sb = [];
|
127
|
-
|
128
|
-
while ((m = pattern.exec(css)) !== null) {
|
129
|
-
|
130
|
-
sb.push(css.substring(index, m.index));
|
131
|
-
|
132
|
-
isFilter = m[1];
|
133
|
-
|
134
|
-
if (isFilter) {
|
135
|
-
// Restore, maintain case, otherwise filter will break
|
136
|
-
sb.push(m[1] + "#" + (m[2] + m[3] + m[4] + m[5] + m[6] + m[7]));
|
137
|
-
} else {
|
138
|
-
if (m[2].toLowerCase() == m[3].toLowerCase() &&
|
139
|
-
m[4].toLowerCase() == m[5].toLowerCase() &&
|
140
|
-
m[6].toLowerCase() == m[7].toLowerCase()) {
|
141
|
-
|
142
|
-
// Compress.
|
143
|
-
sb.push("#" + (m[3] + m[5] + m[7]).toLowerCase());
|
144
|
-
} else {
|
145
|
-
// Non compressible color, restore but lower case.
|
146
|
-
sb.push("#" + (m[2] + m[3] + m[4] + m[5] + m[6] + m[7]).toLowerCase());
|
147
|
-
}
|
148
|
-
}
|
149
|
-
|
150
|
-
index = pattern.lastIndex = pattern.lastIndex - m[8].length;
|
151
|
-
}
|
152
|
-
|
153
|
-
sb.push(css.substring(index));
|
154
|
-
|
155
|
-
return sb.join("");
|
156
|
-
};
|
157
|
-
|
158
|
-
YAHOO.compressor.cssmin = function (css, linebreakpos) {
|
159
|
-
|
160
|
-
var startIndex = 0,
|
161
|
-
endIndex = 0,
|
162
|
-
i = 0, max = 0,
|
163
|
-
preservedTokens = [],
|
164
|
-
comments = [],
|
165
|
-
token = '',
|
166
|
-
totallen = css.length,
|
167
|
-
placeholder = '';
|
168
|
-
|
169
|
-
css = this._extractDataUrls(css, preservedTokens);
|
170
|
-
|
171
|
-
// collect all comment blocks...
|
172
|
-
while ((startIndex = css.indexOf("/*", startIndex)) >= 0) {
|
173
|
-
endIndex = css.indexOf("*/", startIndex + 2);
|
174
|
-
if (endIndex < 0) {
|
175
|
-
endIndex = totallen;
|
176
|
-
}
|
177
|
-
token = css.slice(startIndex + 2, endIndex);
|
178
|
-
comments.push(token);
|
179
|
-
css = css.slice(0, startIndex + 2) + "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + (comments.length - 1) + "___" + css.slice(endIndex);
|
180
|
-
startIndex += 2;
|
181
|
-
}
|
182
|
-
|
183
|
-
// preserve strings so their content doesn't get accidentally minified
|
184
|
-
css = css.replace(/("([^\\"]|\\.|\\)*")|('([^\\']|\\.|\\)*')/g, function (match) {
|
185
|
-
var i, max, quote = match.substring(0, 1);
|
186
|
-
|
187
|
-
match = match.slice(1, -1);
|
188
|
-
|
189
|
-
// maybe the string contains a comment-like substring?
|
190
|
-
// one, maybe more? put'em back then
|
191
|
-
if (match.indexOf("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_") >= 0) {
|
192
|
-
for (i = 0, max = comments.length; i < max; i = i + 1) {
|
193
|
-
match = match.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", comments[i]);
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
// minify alpha opacity in filter strings
|
198
|
-
match = match.replace(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi, "alpha(opacity=");
|
199
|
-
|
200
|
-
preservedTokens.push(match);
|
201
|
-
return quote + "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___" + quote;
|
202
|
-
});
|
203
|
-
|
204
|
-
// strings are safe, now wrestle the comments
|
205
|
-
for (i = 0, max = comments.length; i < max; i = i + 1) {
|
206
|
-
|
207
|
-
token = comments[i];
|
208
|
-
placeholder = "___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___";
|
209
|
-
|
210
|
-
// ! in the first position of the comment means preserve
|
211
|
-
// so push to the preserved tokens keeping the !
|
212
|
-
if (token.charAt(0) === "!") {
|
213
|
-
preservedTokens.push(token);
|
214
|
-
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
|
215
|
-
continue;
|
216
|
-
}
|
217
|
-
|
218
|
-
// \ in the last position looks like hack for Mac/IE5
|
219
|
-
// shorten that to /*\*/ and the next one to /**/
|
220
|
-
if (token.charAt(token.length - 1) === "\\") {
|
221
|
-
preservedTokens.push("\\");
|
222
|
-
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
|
223
|
-
i = i + 1; // attn: advancing the loop
|
224
|
-
preservedTokens.push("");
|
225
|
-
css = css.replace("___YUICSSMIN_PRESERVE_CANDIDATE_COMMENT_" + i + "___", "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
|
226
|
-
continue;
|
227
|
-
}
|
228
|
-
|
229
|
-
// keep empty comments after child selectors (IE7 hack)
|
230
|
-
// e.g. html >/**/ body
|
231
|
-
if (token.length === 0) {
|
232
|
-
startIndex = css.indexOf(placeholder);
|
233
|
-
if (startIndex > 2) {
|
234
|
-
if (css.charAt(startIndex - 3) === '>') {
|
235
|
-
preservedTokens.push("");
|
236
|
-
css = css.replace(placeholder, "___YUICSSMIN_PRESERVED_TOKEN_" + (preservedTokens.length - 1) + "___");
|
237
|
-
}
|
238
|
-
}
|
239
|
-
}
|
240
|
-
|
241
|
-
// in all other cases kill the comment
|
242
|
-
css = css.replace("/*" + placeholder + "*/", "");
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
// Normalize all whitespace strings to single spaces. Easier to work with that way.
|
247
|
-
css = css.replace(/\s+/g, " ");
|
248
|
-
|
249
|
-
// Remove the spaces before the things that should not have spaces before them.
|
250
|
-
// But, be careful not to turn "p :link {...}" into "p:link{...}"
|
251
|
-
// Swap out any pseudo-class colons with the token, and then swap back.
|
252
|
-
css = css.replace(/(^|\})(([^\{:])+:)+([^\{]*\{)/g, function (m) {
|
253
|
-
return m.replace(":", "___YUICSSMIN_PSEUDOCLASSCOLON___");
|
254
|
-
});
|
255
|
-
css = css.replace(/\s+([!{};:>+\(\)\],])/g, '$1');
|
256
|
-
css = css.replace(/___YUICSSMIN_PSEUDOCLASSCOLON___/g, ":");
|
257
|
-
|
258
|
-
// retain space for special IE6 cases
|
259
|
-
css = css.replace(/:first-(line|letter)(\{|,)/g, ":first-$1 $2");
|
260
|
-
|
261
|
-
// no space after the end of a preserved comment
|
262
|
-
css = css.replace(/\*\/ /g, '*/');
|
263
|
-
|
264
|
-
|
265
|
-
// If there is a @charset, then only allow one, and push to the top of the file.
|
266
|
-
css = css.replace(/^(.*)(@charset "[^"]*";)/gi, '$2$1');
|
267
|
-
css = css.replace(/^(\s*@charset [^;]+;\s*)+/gi, '$1');
|
268
|
-
|
269
|
-
// Put the space back in some cases, to support stuff like
|
270
|
-
// @media screen and (-webkit-min-device-pixel-ratio:0){
|
271
|
-
css = css.replace(/\band\(/gi, "and (");
|
272
|
-
|
273
|
-
|
274
|
-
// Remove the spaces after the things that should not have spaces after them.
|
275
|
-
css = css.replace(/([!{}:;>+\(\[,])\s+/g, '$1');
|
276
|
-
|
277
|
-
// remove unnecessary semicolons
|
278
|
-
css = css.replace(/;+\}/g, "}");
|
279
|
-
|
280
|
-
// Replace 0(px,em,%) with 0.
|
281
|
-
css = css.replace(/([\s:])(0)(px|em|%|in|cm|mm|pc|pt|ex)/gi, "$1$2");
|
282
|
-
|
283
|
-
// Replace 0 0 0 0; with 0.
|
284
|
-
css = css.replace(/:0 0 0 0(;|\})/g, ":0$1");
|
285
|
-
css = css.replace(/:0 0 0(;|\})/g, ":0$1");
|
286
|
-
css = css.replace(/:0 0(;|\})/g, ":0$1");
|
287
|
-
|
288
|
-
// Replace background-position:0; with background-position:0 0;
|
289
|
-
// same for transform-origin
|
290
|
-
css = css.replace(/(background-position|transform-origin|webkit-transform-origin|moz-transform-origin|o-transform-origin|ms-transform-origin):0(;|\})/gi, function(all, prop, tail) {
|
291
|
-
return prop.toLowerCase() + ":0 0" + tail;
|
292
|
-
});
|
293
|
-
|
294
|
-
// Replace 0.6 to .6, but only when preceded by : or a white-space
|
295
|
-
css = css.replace(/(:|\s)0+\.(\d+)/g, "$1.$2");
|
296
|
-
|
297
|
-
// Shorten colors from rgb(51,102,153) to #336699
|
298
|
-
// This makes it more likely that it'll get further compressed in the next step.
|
299
|
-
css = css.replace(/rgb\s*\(\s*([0-9,\s]+)\s*\)/gi, function () {
|
300
|
-
var i, rgbcolors = arguments[1].split(',');
|
301
|
-
for (i = 0; i < rgbcolors.length; i = i + 1) {
|
302
|
-
rgbcolors[i] = parseInt(rgbcolors[i], 10).toString(16);
|
303
|
-
if (rgbcolors[i].length === 1) {
|
304
|
-
rgbcolors[i] = '0' + rgbcolors[i];
|
305
|
-
}
|
306
|
-
}
|
307
|
-
return '#' + rgbcolors.join('');
|
308
|
-
});
|
309
|
-
|
310
|
-
// Shorten colors from #AABBCC to #ABC.
|
311
|
-
css = this._compressHexColors(css);
|
312
|
-
|
313
|
-
// border: none -> border:0
|
314
|
-
css = css.replace(/(border|border-top|border-right|border-bottom|border-right|outline|background):none(;|\})/gi, function(all, prop, tail) {
|
315
|
-
return prop.toLowerCase() + ":0" + tail;
|
316
|
-
});
|
317
|
-
|
318
|
-
// shorter opacity IE filter
|
319
|
-
css = css.replace(/progid:DXImageTransform\.Microsoft\.Alpha\(Opacity=/gi, "alpha(opacity=");
|
320
|
-
|
321
|
-
// Remove empty rules.
|
322
|
-
css = css.replace(/[^\};\{\/]+\{\}/g, "");
|
323
|
-
|
324
|
-
if (linebreakpos >= 0) {
|
325
|
-
// Some source control tools don't like it when files containing lines longer
|
326
|
-
// than, say 8000 characters, are checked in. The linebreak option is used in
|
327
|
-
// that case to split long lines after a specific column.
|
328
|
-
startIndex = 0;
|
329
|
-
i = 0;
|
330
|
-
while (i < css.length) {
|
331
|
-
i = i + 1;
|
332
|
-
if (css[i - 1] === '}' && i - startIndex > linebreakpos) {
|
333
|
-
css = css.slice(0, i) + '\n' + css.slice(i);
|
334
|
-
startIndex = i;
|
335
|
-
}
|
336
|
-
}
|
337
|
-
}
|
338
|
-
|
339
|
-
// Replace multiple semi-colons in a row by a single one
|
340
|
-
// See SF bug #1980989
|
341
|
-
css = css.replace(/;;+/g, ";");
|
342
|
-
|
343
|
-
// restore preserved comments and strings
|
344
|
-
for (i = 0, max = preservedTokens.length; i < max; i = i + 1) {
|
345
|
-
css = css.replace("___YUICSSMIN_PRESERVED_TOKEN_" + i + "___", preservedTokens[i]);
|
346
|
-
}
|
347
|
-
|
348
|
-
// Trim the final string (for any leading or trailing white spaces)
|
349
|
-
css = css.replace(/^\s+|\s+$/g, "");
|
350
|
-
|
351
|
-
return css;
|
352
|
-
|
353
|
-
};
|
354
|
-
|
355
|
-
exports.compressor = YAHOO.compressor;
|