Skip to content

isPlainObject usage blocks objects with prototype #1405

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
bpostlethwaite opened this issue Feb 22, 2017 · 4 comments
Closed

isPlainObject usage blocks objects with prototype #1405

bpostlethwaite opened this issue Feb 22, 2017 · 4 comments

Comments

@bpostlethwaite
Copy link
Member

@etpinard @alexcjohnson re: an internal conversation.

The Plotly.js usage of isPlainObject appears to prevent objects with a prototype. This doesn't seem to be target behaviour of isPlainObject as Plotly.js seems to only care if the object behaves like an object (duck typing). Allowing prototype objects will make it easier for people to integrate Plotly.js with Typescript among other potential use cases.

@alexcjohnson made the note that it would be best to change the name of the function.

This issue has been encountered by teams actively integrating Plotly.js with a Typescript application.

@etpinard
Copy link
Contributor

maybe switching to is-plain-obj would solve this issue.

@alexcjohnson
Copy link
Collaborator

maybe switching to is-plain-obj would solve this issue.

doesn't look like it - is-plain-obj explicitly looks for prototype to be missing. I notice though that we are already including it at least via color-parse - I wonder if we will need to alter this behavior all the way down our dep tree? that could be painful...

I don't think there's anything wrong with omitting the prototype check - hey, it works for imagetest, right? I imagine people could find a way to construct something that would cause errors, but in general it seems like simple prototyped objects work fine in our framework, and they seem to JSON.stringify fine for portability too. If we can write some end-to-end tests with some of the prototyped objects people really want to use I'd be OK with just loosening up the condition.

@jefshe
Copy link

jefshe commented Dec 12, 2018

Non-standard use case, but this also prevents plain javascript objects being passed into an iframe from working as well

@alexcjohnson
Copy link
Collaborator

Closing as #5151 is a more up-to-date duplicate

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

No branches or pull requests

4 participants