Skip to content
This repository was archived by the owner on Mar 11, 2021. It is now read-only.

Commit e7cf658

Browse files
author
bencompton
committed
More performance optimizations
1 parent da2f8a7 commit e7cf658

1 file changed

Lines changed: 10 additions & 32 deletions

File tree

src/utils/reactify-vue/react-element-creation/PropsProcessor.ts

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,6 @@ const camelCase = (str) => {
1414
return (camelCase as any).replacement[str];
1515
};
1616

17-
const hasOwn = {}.hasOwnProperty;
18-
19-
const classNames = (...args: any[]) => {
20-
const classes = [];
21-
22-
for (let i = 0, length = args.length; i < length; i++) {
23-
let arg = args[i];
24-
25-
if (!arg) continue;
26-
27-
let argType = typeof arg;
28-
29-
if (argType === 'string' || argType === 'number') {
30-
classes.push(arg);
31-
} else if (Array.isArray(arg)) {
32-
classes.push(classNames.apply(null, arg));
33-
} else if (argType === 'object') {
34-
for (let key in arg) {
35-
if (arg[key]) {
36-
classes.push(key);
37-
}
38-
}
39-
}
40-
}
41-
42-
return classes.join(' ');
43-
};
44-
4517
const attributeMap = {
4618
autocapitalize: {
4719
componentNames: ['input', 'textarea', 'select'],
@@ -171,10 +143,16 @@ export class PropsProcessor {
171143
if (args.staticClass) {
172144
classObject[args.staticClass] = true;
173145
}
174-
175-
if (Object.keys(classObject).length) {
176-
props.className = classNames(classObject);
177-
}
146+
147+
const classes = [];
148+
149+
for (let key in classObject) {
150+
if (classObject[key]) {
151+
classes.push(key);
152+
}
153+
}
154+
155+
props.className = classes.join(' ');
178156
}
179157

180158
private getStyle(args, vueComponent, props) {

0 commit comments

Comments
 (0)