react-json-tree icon indicating copy to clipboard operation
react-json-tree copied to clipboard

Replaced ES6 instance methods with static one

Open soulman-is-good opened this issue 8 years ago • 7 comments
trafficstars

What is done in this PR

  • Replaced ES6 insance methods Array.prototype.find with Array.find as babel-plugin-transform-runtime does not polyfill them in such a way (see why and also see readme from core-js, without global scope pollution).
  • Updated sortObjectKeys handling according to MDN

Currently react-json-tree doesn't work on IE and Edge 11, see MDN

@alexkuz please consider this changes.

soulman-is-good avatar Apr 09 '17 07:04 soulman-is-good

Thank you! But I'd just use a polyfill actually

import 'core-js/fn/array/find';

alexkuz avatar Apr 09 '17 11:04 alexkuz

importing this will pollute global scope by modifying Array.prototype directly. But since you are using transform-runtime (and I think this is the right way) the es6 instance method should be written in static way. Please @alexkuz consider my answer, I want to use your lib badly, but I have to support IE9+ )

soulman-is-good avatar Apr 09 '17 12:04 soulman-is-good

And I would also include fix for this issue in this PR

image

~~Can you give a hint, what you are waiting sortObjectKeys should be?~~

Bad question. Description is on the README. So I'll just update this file too

soulman-is-good avatar Apr 09 '17 12:04 soulman-is-good

I think the best solution here would be not using find at all, I'll get rid of it in the next version. For now, if you're using it in an app, just add a polyfill.

alexkuz avatar Apr 09 '17 14:04 alexkuz

(Array.find doesn't seem to me like an appropriate solution, it's not in specs so technically this code is not valid)

alexkuz avatar Apr 09 '17 14:04 alexkuz

It would be great to get the sortObjectKeys change merged in, at least. The component breaks when sortObjectTrees is simply set to true.

wdcryer avatar Dec 19 '17 20:12 wdcryer

Hi, can this PR be merged/released?

gitgrimbo avatar Jun 14 '18 08:06 gitgrimbo