Skip to content
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

Fix isAlien to properly identify built-in functions. Partially fixes #18244 #123

Closed
wants to merge 1 commit into from

Conversation

@mlabrec
Copy link

mlabrec commented Nov 15, 2014

Also made the function return bool for falsy arguments.

@dylans

This comment has been minimized.

Copy link
Member

dylans commented Jan 29, 2015

@mlabrec unfortunately since this original pull request, we've updated all of our unit tests in core from DOH to Intern. Would you be willing to update your tests by any chance?

@dylans dylans added this to the 1.11 milestone Jan 29, 2015
@mlabrec mlabrec force-pushed the mlabrec:t18244 branch from 9f4dcd8 to e047039 Jan 31, 2015
@mlabrec

This comment has been minimized.

Copy link
Author

mlabrec commented Jan 31, 2015

Sure, I've now updated my tests to use the new test file.

@dylans

This comment has been minimized.

Copy link
Member

dylans commented Sep 11, 2015

Thanks, and sorry for the delayed response. @bryanforbes or @kfranqueiro any objections to this patch for 1.11 (it looks like it's passing the provided tests)

@@ -307,7 +307,7 @@ define(["./kernel", "../has", "../sniff"], function(dojo, has){
// summary:
// Returns true if it is a built-in function or some other kind of
// oddball that *should* report as a function but doesn't
return it && !lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean
return !!it && lang.isFunction(it) && /\{\s*\[native code\]\s*\}/.test(String(it)); // Boolean

This comment has been minimized.

Copy link
@bryanforbes

bryanforbes Sep 11, 2015

Member

Use Boolean(it) instead of !!it.

This comment has been minimized.

Copy link
@wkeese

wkeese Sep 11, 2015

Member

I've never heard that rule before. The current syntax is terser.

I have a more basic objection though. The function no longer does what it says. The summary (emphasis added) is

Returns true if it is a built-in function or some other kind of oddball that should report as a function but doesn't

Now you've changed it to only report things that do report as functions. Why is that?

Also, the ticket (https://bugs.dojotoolkit.org/ticket/18244) says something about _toArray(), but you haven't changed anything with toArray().

This comment has been minimized.

Copy link
@dylans

dylans Sep 11, 2015

Member

I think Boolean() is the preferred syntax for TS and ES6, but I agree that it doesn't really matter here, and !! is far more commonly used in Dojo 1.x.

I agree with the other points made. I was trying to figure out if the intent was really to change the second condition to be the opposite of what it is today, or if the real issue is to just make it be guaranteed to be truthy?

This comment has been minimized.

Copy link
@wkeese

wkeese Sep 11, 2015

Member

Judging from the text in https://bugs.dojotoolkit.org/ticket/18244, and also by @mlabrec's initial comment to this PR "Also made the function return bool for falsy arguments.", I think the main point was to change the !isFunction() to isFunction().

And I assume that's because the bug/PR author didn't carefully read the spec for what isAlien() is supposed to do. It's called isAlien(), not isNativeOrNormalFunction().

@dylans dylans modified the milestones: 1.12, 1.11 Dec 22, 2015
@dylans dylans modified the milestones: 1.13, 1.12 Sep 28, 2016
@dylans

This comment has been minimized.

Copy link
Member

dylans commented Jan 15, 2017

Closing this as wontfix, but please reopen if there's a new patch that addresses feedback.

@dylans dylans closed this Jan 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.