Skip to content

Commit 02abb61

Browse files
committed
reduce parser.js
1 parent b2247fc commit 02abb61

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

parser.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,30 @@ let UNITLESS = {
2727
'stroke-width': true
2828
}
2929

30-
let { fromCharCode } = String;
30+
let { fromCharCode } = String
3131

3232
function dashify(str) {
33-
let result = '';
34-
let i = 0;
35-
let len = str.length;
36-
let code;
33+
if (str === 'cssFloat') return 'float'
3734

38-
if (str[0] === 'm' && str[1] === 's') result += fromCharCode(45); // '-'
35+
let result = ''
36+
let i = 0
37+
let len = str.length
38+
let code
39+
40+
if (str.startsWith('ms')) result += fromCharCode(45) // '-'
3941

4042
for (; i < len; i++) {
41-
code = str[i].charCodeAt(0);
43+
code = str[i].charCodeAt(0)
4244

4345
if (code > 64 && code < 91) {
44-
result += fromCharCode(45) + fromCharCode(code + 32);
45-
continue;
46+
result += fromCharCode(45) + fromCharCode(code + 32)
47+
continue
4648
}
4749

48-
result += fromCharCode(code);
50+
result += fromCharCode(code)
4951
}
5052

51-
return result;
53+
return result
5254
}
5355

5456
function decl(parent, name, value) {
@@ -66,8 +68,6 @@ function decl(parent, name, value) {
6668
}
6769
}
6870

69-
if (name === 'css-float') name = 'float'
70-
7171
if (IMPORTANT.test(value)) {
7272
value = value.replace(IMPORTANT, '')
7373
parent.push(postcss.decl({ prop: name, value, important: true }))
@@ -89,7 +89,7 @@ function parse(obj, parent) {
8989
let name, node, value
9090
for (name in obj) {
9191
value = obj[name]
92-
if (value === null || typeof value === 'undefined') {
92+
if (value == null) {
9393
continue
9494
} else if (name[0] === '@') {
9595
let parts = name.match(/@(\S+)(\s+([\W\w]*)\s*)?/)

0 commit comments

Comments
 (0)