Skip to content

Enforce is-plain-object #792

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

Merged
merged 2 commits into from
Jul 29, 2016
Merged

Enforce is-plain-object #792

merged 2 commits into from
Jul 29, 2016

Conversation

etpinard
Copy link
Contributor

Lib.isPlainObject fails in our imagetest docker image test container at the moment.

More specifically,

Object.getPrototypeOf(obj) === Object.prototype

is false for plain objects in imagetest. This behaviour is due to how the async utility lash applies functions to objects. Making a fix lash and/or the imagetest would have been arduous, so I decided to patch Lib.isPlainObject instead.

The patch in c09cbb3 makes Lib.isPlainObject only check for

Object.prototype.toString.call(obj) === '[object Object]'

in nw.js environments. This lead to

function A() {}

Lib.isPlainObject(new A());

to return true. I'd argue that this is fine in imagetest where request bodies are JSON stringified and JSON parsed before plotting - note that JSON.parse(JSON.stringify(new A()) returns {}.

Commit e1f6818 enforces Lib.isPlainObject is the source files.

etpinard added 2 commits July 28, 2016 18:20
- to make sure that plotly.js is compatible with async
  request handles (e.g. lash)
- side effect: isPlainObject(new Constructor()) now returns true
  in nw.js
@etpinard etpinard added this to the v1.16.0 milestone Jul 29, 2016
@etpinard etpinard merged commit c9a6549 into master Jul 29, 2016
@etpinard etpinard deleted the enforce-is-plain-object branch July 29, 2016 18:07
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

Successfully merging this pull request may close these issues.

1 participant