Skip to content

Commit ec73dc5

Browse files
committed
refactor: fix unit
1 parent 29225ed commit ec73dc5

File tree

2 files changed

+56
-60
lines changed

2 files changed

+56
-60
lines changed

.jest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11

22
const transformIgnorePatterns = [
33
'/dist/',
4-
// Ignore modules without es dir.
5-
// Update: @babel/runtime should also be transformed
6-
// 'node_modules/(?!.*(@babel|lodash-es))',
7-
// 'node_modules/(?!@ant-design/icons-vue|@ant-design/icons-svg|lodash-es)/',
84
];
95
const testPathIgnorePatterns = ['/node_modules/', 'node'];
106
if (process.env.WORKFLOW === 'true') {

src/utils/util.ts

Lines changed: 56 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -4,67 +4,67 @@ export const isArray = Array.isArray;
44
export const isString = val => typeof val === 'string';
55
export const isSymbol = val => typeof val === 'symbol';
66
export const isObject = val => val !== null && typeof val === 'object';
7-
const onRE = /^on[^a-z]/;
8-
const isOn = key => onRE.test(key);
7+
// const onRE = /^on[^a-z]/;
8+
// const isOn = key => onRE.test(key);
99

10-
const cacheStringFunction = fn => {
11-
const cache = Object.create(null);
12-
return str => {
13-
const hit = cache[str];
14-
return hit || (cache[str] = fn(str));
15-
};
16-
};
17-
const camelizeRE = /-(\w)/g;
18-
const camelize = cacheStringFunction(str => {
19-
return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
20-
});
10+
// const cacheStringFunction = fn => {
11+
// const cache = Object.create(null);
12+
// return str => {
13+
// const hit = cache[str];
14+
// return hit || (cache[str] = fn(str));
15+
// };
16+
// };
17+
// const camelizeRE = /-(\w)/g;
18+
// const camelize = cacheStringFunction(str => {
19+
// return str.replace(camelizeRE, (_, c) => (c ? c.toUpperCase() : ''));
20+
// });
2121

22-
const hyphenateRE = /\B([A-Z])/g;
23-
const hyphenate = cacheStringFunction(str => {
24-
return str.replace(hyphenateRE, '-$1').toLowerCase();
25-
});
22+
// const hyphenateRE = /\B([A-Z])/g;
23+
// const hyphenate = cacheStringFunction(str => {
24+
// return str.replace(hyphenateRE, '-$1').toLowerCase();
25+
// });
2626

27-
const capitalize = cacheStringFunction(str => {
28-
return str.charAt(0).toUpperCase() + str.slice(1);
29-
});
27+
// const capitalize = cacheStringFunction(str => {
28+
// return str.charAt(0).toUpperCase() + str.slice(1);
29+
// });
3030

31-
const hasOwnProperty = Object.prototype.hasOwnProperty;
32-
const hasOwn = (val, key) => hasOwnProperty.call(val, key);
31+
// const hasOwnProperty = Object.prototype.hasOwnProperty;
32+
// const hasOwn = (val, key) => hasOwnProperty.call(val, key);
3333

34-
// change from vue sourcecode
35-
function resolvePropValue (options, props, key, value) {
36-
const opt = options[key];
37-
if (opt != null) {
38-
const hasDefault = hasOwn(opt, 'default');
39-
// default values
40-
if (hasDefault && value === undefined) {
41-
const defaultValue = opt.default;
42-
value = opt.type !== Function && isFunction(defaultValue) ? defaultValue() : defaultValue;
43-
}
44-
// boolean casting
45-
if (opt[0 /* shouldCast */]) {
46-
if (!hasOwn(props, key) && !hasDefault) {
47-
value = false;
48-
} else if (opt[1 /* shouldCastTrue */] && (value === '' || value === hyphenate(key))) {
49-
value = true;
50-
}
51-
}
52-
}
53-
return value;
54-
}
34+
// // change from vue sourcecode
35+
// function resolvePropValue (options, props, key, value) {
36+
// const opt = options[key];
37+
// if (opt != null) {
38+
// const hasDefault = hasOwn(opt, 'default');
39+
// // default values
40+
// if (hasDefault && value === undefined) {
41+
// const defaultValue = opt.default;
42+
// value = opt.type !== Function && isFunction(defaultValue) ? defaultValue() : defaultValue;
43+
// }
44+
// // boolean casting
45+
// if (opt[0 /* shouldCast */]) {
46+
// if (!hasOwn(props, key) && !hasDefault) {
47+
// value = false;
48+
// } else if (opt[1 /* shouldCastTrue */] && (value === '' || value === hyphenate(key))) {
49+
// value = true;
50+
// }
51+
// }
52+
// }
53+
// return value;
54+
// }
5555

56-
export function getDataAndAriaProps (props) {
57-
return Object.keys(props).reduce((memo, key) => {
58-
if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
59-
memo[key] = props[key];
60-
}
61-
return memo;
62-
}, {});
63-
}
56+
// export function getDataAndAriaProps (props) {
57+
// return Object.keys(props).reduce((memo, key) => {
58+
// if (key.substr(0, 5) === 'data-' || key.substr(0, 5) === 'aria-') {
59+
// memo[key] = props[key];
60+
// }
61+
// return memo;
62+
// }, {});
63+
// }
6464

65-
const guid = () => {
66-
const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
67-
return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4() + s4() + s4()}`;
68-
};
65+
// const guid = () => {
66+
// const s4 = () => Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
67+
// return `${s4() + s4()}-${s4()}-${s4()}-${s4()}-${s4() + s4() + s4()}`;
68+
// };
6969

70-
export { guid, isOn, cacheStringFunction, camelize, hyphenate, capitalize, resolvePropValue };
70+
// export { isOn, cacheStringFunction, camelize, hyphenate, capitalize };

0 commit comments

Comments
 (0)