IE8 fix: filter __proto__ from for..in loops #2209
Closed
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.
D3 is currently out of commission in IE8 thanks to some tight for..in loops in the
d3.map()implementation. When d3.js is executed, IE8 fails while iterating overd3_svg_lineInterpolatorswhen it hits the__proto__key:Because, unfortunately, in IE8:
Which means that we have to use
hasOwnProperty()instead of just theinoperator. This PR suggests one fix (for which the tests pass, and I've confirmed it works in IE8), but it might have performance implications. For instance, instead of the locally boundhas(key)these functions could callthis.has(key)instead, which might be faster.I haven't looked too closely to see if there are any other places in d3 where this might apply, but the d3.map constructor might be a candidate.