Fix set iterableToString test on IE11 #1230
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Purpose (TL;DR)
This fixes the failing tests on IE11 introduced in #1215 .
Background
Our implementation of
typeOf
was too simple and didn't handle older implementations ofMap
s andSet
s.Even with the
if
clauses guarding theMap
andSet
related tests they would fail, because IE11 did implement them, however, IE11's implementation wasn't following the ECMA standard. This caused our type detection to fail without recognizing these object's types correctly.Also, IE11's
Set
constructor was a bit weird and didn't accept an array of elements as argument, so I had to use multiple.add
calls to add elements to aSet
.Solution
I added
type-detect
to solve thetypeOf
related problem.I'm not sure everyone agrees on that. So, if you don't want that please let me know and I'll dedicate more time to rewrite
typeOf
and make it compatible with older browsers implementations ofMap
s andSet
s. However, this library is maintained by everyone atChai
and other awesome contributors and it's pretty stable and has good performance.IMO, having less code to maintain is always good and maybe we can join efforts on that library making it better for everyone.
I have also changed the
Set
constructor on a test in order to use an IE11 compliant way of creating Sets.How to verify - mandatory
npm install
npm run test
Let me know if you disagree with anything and I'll happily fix it.
PS.: Sorry for breaking your build! 😅