Skip to content

Commit 1f277a2

Browse files
committed
Optimize build.mjs size
1 parent bcd229a commit 1f277a2

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/build.mjs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
const TAG_SET = 0;
2-
const PROPS_SET = 1;
3-
const PROPS_ASSIGN = 2;
4-
const CHILD_RECURSE = 3;
5-
const CHILD_APPEND = 4;
1+
const TAG_SET = 1;
2+
const PROPS_SET = 2;
3+
const PROPS_ASSIGN = 3;
4+
const CHILD_RECURSE = 4;
5+
const CHILD_APPEND = 0;
66

77
const MODE_SLASH = 0;
88
const MODE_TEXT = 1;
9-
const MODE_WHITESPACE = 3;
10-
const MODE_TAGNAME = 4;
11-
const MODE_ATTRIBUTE = 5;
9+
const MODE_WHITESPACE = 2;
10+
const MODE_TAGNAME = 3;
11+
const MODE_ATTRIBUTE = 4;
1212

1313
export const evaluate = (h, current, fields, args) => {
1414
for (let i = 1; i < current.length; i++) {
1515
const field = current[i++];
1616
const value = field ? fields[field] : current[i];
1717

18-
const code = current[++i];
19-
if (code === TAG_SET) {
18+
if (current[++i] === TAG_SET) {
2019
args[0] = value;
2120
}
22-
else if (code === PROPS_SET) {
21+
else if (current[i] === PROPS_SET) {
2322
(args[1] = args[1] || {})[current[++i]] = value;
2423
}
25-
else if (code === PROPS_ASSIGN) {
24+
else if (current[i] === PROPS_ASSIGN) {
2625
args[1] = Object.assign(args[1] || {}, value);
2726
}
28-
else if (code === CHILD_RECURSE) {
29-
// eslint-disable-next-line prefer-spread
27+
else if (current[i]) {
28+
// code === CHILD_RECURSE
3029
args.push(h.apply(null, evaluate(h, value, fields, ['', null])));
3130
}
32-
else { // code === CHILD_APPEND
31+
else {
32+
// code === CHILD_APPEND
3333
args.push(value);
3434
}
3535
}

0 commit comments

Comments
 (0)