Skip to content

isMap, isSet and isWeakMap functions implemented, which Fix IE11 and Firefox tests #2466

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

Closed

Conversation

MahmudH
Copy link
Contributor

@MahmudH MahmudH commented Mar 10, 2016

This is following our conversation from #2464 to close #2449.

underscore.js Outdated
}
var objCtor = obj.constructor,
objCtorString = Function.prototype.toString.call(objCtor);
return objCtorString === 'function ' + name + '() { [native code] }';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the string value of the constructor aligns with this it's not guaranteed to be this format which is why a reference to the constructor's to-stringed value was used instead of manually generating it in the reference implementation.

@gwpmad
Copy link
Contributor

gwpmad commented Mar 11, 2016

Thanks, I'm going to try to fix this. Going to put a helper function in just above it, hopefully that's ok!

@gwpmad
Copy link
Contributor

gwpmad commented Mar 11, 2016

Hi, I've updated the pull request to hopefully address the issues @jdalton mentions. I've basically added a returnTag helper function that brings in some of the functionality from the lodash _getTag.js file. There are a number of ternary statements in there so that older browsers don't get exposed to Maps/Sets/WeakMaps resulting in Travis fails.

Also @jdalton, re your second note, please let me know if there's a unit test you'd like me to add for objCtor not being a Function. I'm currently not sure what I could use to get a constructor that isn't a function.

Thanks as ever for your help and feedback!

@MahmudH
Copy link
Contributor Author

MahmudH commented Apr 18, 2016

HI @jdalton. Any updates on this? Thanks

@@ -746,7 +746,6 @@
}
if (typeof Set === 'function') {
var obj = new Set();
obj.add(1).add('string').add(false).add({});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you test code is essentially correct, but it breaks in some environments due to lack of support, then just deleting that test code is never the right solution. In this case it could have been fixed by just not chaining the calls but repeating obj.add four times on a separate line.

}
}
return objectTag;
};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very large workaround just to fix three isType functions for one version of one browser. I don't like the size of it and I don't like the fact that it is being applied to all the other isType functions as well.

@jgonggrijp
Copy link
Collaborator

This is fix for a real bug but the fix needs to be much more elegant.

@jgonggrijp jgonggrijp added the bug label May 9, 2020
@jgonggrijp
Copy link
Collaborator

Superseded by #2884.

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

Successfully merging this pull request may close these issues.

isMap, isSet, isWeakSet, isWeakMap
4 participants