-
-
Notifications
You must be signed in to change notification settings - Fork 670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added check for native js objects to __instanceof #2857
added check for native js objects to __instanceof #2857
Conversation
… with native objects where typof returns "object" now added function for getting js [[Class]] added function for resolving native classes added handling of native objects to getClass added null-check to Type.getClassName to avoid error when a native class is used added resolving of native classes to Type.resolveClass
Where would I add special unit tests for testing this? I see Std.is is tested mainly in TestReflect? Is there a place for special js tests or would add an Issue under /issues? |
Now that you have an issue ID it makes sense to add an issue test. I'm trying to write all tests as issue tests from now on because it has several advantages. |
OK, for js-specific stuff, like checking DOM-objects, do you add #if js to the Issue then? And is it enough to only run compile-js.hxml? |
I would just wrap the test class fields in |
Ok, I'll add some tests. |
I added some first tests. Will try to make up some more. |
This is great! I was working on this problem for a couple of days, and couldn't come up with a good solution. This method seems to work cross browser. |
Using "window" / "global" is not good, since it will return false positive, for instance resolveClass("addEventListener"). Also, I'm not a big fan of having getClass doing an extra memory allocation (by calling toString()), since this should significantly slowdown both getClass and instanceOf |
Couldn't the check be inverted, i.e. if |
Type.resolveClass doesn't work anyway, you would need the native class, i.e. HTMLVideoElement instead of js.html.VideoElement. So I would only use __resolveNativeClass in getClass but maybe that's not really needed for native objects... |
modified getClass (check for __class__ first) only use __isNativeObj on objects added fixed reference to {}.toString added exclusions to __nativeClassName removed __resolveNativeClass from Type.resolveClass (doesn't work)
This looks good to me now because all the native handling only happens if |
Just a last nitpick maybe, we could check for instanceof before checking nativeClass ? |
You mean in |
Will this be merged eventually? |
Ok sounds fine, let's merge and hopefully this will not create any issue. |
added check for native js objects to __instanceof
The test case needs to be revised. IE8:
IE9:
|
@mockey any suggestion to replace these ? I'm not sure which classes values are actually defined in IE8 |
Oh, IE, hmm. Are IE8 and IE9 new? I think TravisCI didn't fail in April. |
Our Travis setting does not run SauceLabs browser tests for pull request, due to the use of secure env variables for SauceLabs auth. That is a sad limitation. |
Could we either fix this or disable the test? It's quite irritating to have a constant fail case like that. |
I have no time for a fix atm. So better disable it for now. I will look into it at the weekend. |
Alright, thanks for the heads up. I have disabled the test for now. |
Std.is should work with native objects where typeof returns "object" now
added function for getting js [[Class]]
added function for resolving native classes
added handling of native objects to getClass
added null-check to Type.getClassName to avoid error when a native class is used
added resolving of native classes to Type.resolveClass