Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit a64e6f0

Browse files
committed
fix: check prototype first to conclude if its a class
After minifying your javascript it is possible that the class names get changed, such that they are no more adhering to the standard of starting a class name with a capital letter. Thus the isClass util fun returns false in such cases, even though the class has some fields set in the prototype object. The solution is to first check the prototype object for keys and then check for class name. Fixes #92
1 parent 70606e1 commit a64e6f0

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

src/util.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@ function isUpperCase(char) {
77

88

99
function isClass(clsOrFunction) {
10-
if (clsOrFunction.name) {
10+
if (Object.keys(clsOrFunction.prototype).length > 0){
11+
return true;
12+
}else if (clsOrFunction.name) {
1113
return isUpperCase(clsOrFunction.name.charAt(0));
1214
}
13-
14-
return Object.keys(clsOrFunction.prototype).length > 0;
15+
return false;
1516
}
1617

1718

0 commit comments

Comments
 (0)