Skip to content
This repository has been archived by the owner on Jul 29, 2019. It is now read-only.

DataSet.update doesn't work for objects from iframe (gwt usage issue) #2097

Closed
ggwp0101 opened this issue Sep 16, 2016 · 3 comments
Closed

Comments

@ggwp0101
Copy link

https://github.com/almende/vis/blob/master/lib/DataSet.js checks data parameter in update method using data instanceof Object. It won't work if data has been created in iframe.
Here is explanation:
https://groups.google.com/forum/#!topic/google-web-toolkit/CdgvqajYeDI

Proposal if to move instanceof checks to separate class as util methods and introduce additional check using toString method, like:
Object.prototype.toString.call(o) === '[object Object]

Thanks

@mojoaxel
Copy link
Member

@AleksejDomash Thanks for reporting this. Could you please provide a simple example (e.g. jsbin) that shows how to reproduce this problem!?

@ZacBrownBand
Copy link
Contributor

ZacBrownBand commented Jan 25, 2017

I ran into this same issue but while using multiple windows. I have a fix and will be opening a pr momentarily. First I wanted to update this issue.

I found a post on SO explaining why this is an issue,

Since your window's Object and the source window's Object aren't the same thing, an instance of one won't be an instance of the other.
source

Here is a jsfiddle showing the issue (and a fix) using a iFrame. Link here

In case there is a link break:

<iframe id="other" style="width:500px"></iframe>
var other = document.getElementById('other');

window.obj = {};

other.contentWindow.document.write('<pre><script>' +
  'var obj = parent.obj;' +
  'document.write("obj instanceof Object          -> ");' +
  'document.writeln(obj instanceof Object);' +
  'document.write("obj && typeof obj === &quot;object&quot; -> ");' +
  'document.writeln(obj && typeof obj === "object");' +
  '<\/script></pre>');

screen shot 2017-01-25 at 1 45 54 pm

@yotamberk
Copy link
Contributor

closed with #2631. Thanks @ZacBrownBand!

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

No branches or pull requests

5 participants