-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
isMap, isSet and isWeakMap functions implemented, which Fix IE11 and Firefox tests #2466
Conversation
underscore.js
Outdated
} | ||
var objCtor = obj.constructor, | ||
objCtorString = Function.prototype.toString.call(objCtor); | ||
return objCtorString === 'function ' + name + '() { [native code] }'; |
There was a problem hiding this comment.
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.
Thanks, I'm going to try to fix this. Going to put a helper function in just above it, hopefully that's ok! |
…eate Map, WeakMap and Set
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! |
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({}); |
There was a problem hiding this comment.
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; | ||
}; |
There was a problem hiding this comment.
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.
This is fix for a real bug but the fix needs to be much more elegant. |
Superseded by #2884. |
This is following our conversation from #2464 to close #2449.