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

isClass and minification #73

Open
gah-boh opened this issue Oct 2, 2014 · 3 comments
Open

isClass and minification #73

gah-boh opened this issue Oct 2, 2014 · 3 comments

Comments

@gah-boh
Copy link

gah-boh commented Oct 2, 2014

I've been playing around with this and I believe I found a problem with the way it determines if it's a class when minified.

So this will use ClassProvider because the class name starts with uppercase:

class Person {
// code...
} 

when minified it will turn it into something along the lines of:

class r {
// code...
}

That will obviously throw errors because it will incorrectly use the FactoryProvider instead

The only way I've managed to make it work has been to write:

var Person = class {
// code...
}

This will obviously not have anything in the name property so it will work because it will not go into the if (clsOrFunction.name) block in the isClass function and check the prototype instead of the name.

I've been trying to think what else could work for determining if it's a class or not, but this seems like a tricky issue...

@Alxandr
Copy link

Alxandr commented Oct 2, 2014

How about checking the prototype? If it's a Function object, then it's a function. If it's a sub-type of Function, then it's a class (most likely)?

@gah-boh
Copy link
Author

gah-boh commented Oct 2, 2014

If there is no name property it checks the prototype.length in the isClass function. The main problem I see is that it checks the name property first

I'm not sure what you mean by sub-type of function. Don't want to assume anything, can you clarify please?

@Alxandr
Copy link

Alxandr commented Oct 3, 2014

Oh, wait. I'm completely thinking wrongly about this. My bad.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants