Skip to content
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

src method failed between frames #1195

Closed
shmulik opened this issue May 7, 2014 · 5 comments
Closed

src method failed between frames #1195

shmulik opened this issue May 7, 2014 · 5 comments

Comments

@shmulik
Copy link
Contributor

shmulik commented May 7, 2014

I am creating my playlist in the main window.
Each playlist have an array of sources.
The videojs player is running in an Iframe.
Each time an Item on the playlist is clicked, I am changing the src of the player using the src method, passing it the sources array.
But, since the code in "vjs.Player.prototype.src" function use "if (source instanceof Array)", and since the array of sources was created in another frame, the result of instanceof is false, and the sources not updated.
You should instead, use "Array.isArray(source)" to do the test for array.
Read more about "instanceof and multiple context (e.g. frames or windows)" here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/instanceof

@shmulik shmulik changed the title src method failed netween frames src method failed between frames May 7, 2014
@mmcc
Copy link
Member

mmcc commented May 8, 2014

I don't believe Array.isArray is supported in IE8, so it's not quite as easy as just using that instead. Do you have a reduced test case for this example somewhere?

@gkatsev
Copy link
Member

gkatsev commented May 10, 2014

We should be able to do a similar shim to how we're doing Object.create,

vjs.obj.isArray = Array.isArray || function(arr) {
  return Object.prototype.toString.call(arr) === "[object Array]";
};

@heff
Copy link
Member

heff commented May 16, 2014

Yeah, that sounds good to me. @shmulik, do you want to make a pull request for this?

@heff heff added the confirmed label May 16, 2014
shmulik added a commit to shmulik/video.js that referenced this issue May 18, 2014
instanceof Array, will not work on arrays created cross frames.
Array,isArray is the method to check if an object isArray across frames.
IE8 does not suppoort the Array.isArray method, so we have to create a shim to support all browsers.
shmulik added a commit to shmulik/video.js that referenced this issue May 18, 2014
instanceof Array, will not work on arrays created cross frames.
Array,isArray is the method to check if an object isArray across frames.
IE8 does not suppoort the Array.isArray method, so we have to create a shim to support all browsers.
@shmulik
Copy link
Contributor Author

shmulik commented May 18, 2014

Thanks all.
@heff , I've just created my first pull request:-)
Hope I did it correctly.
#1218

shmulik added a commit to shmulik/video.js that referenced this issue May 19, 2014
vjs.Player.prototype.src uses the instanceof Array method.
This will not work for arrays created on another frame,
Instead of instanceof we should use Array.isArray, but this is not supported on IE8.
So vjs.obj.isArray shim was created for the isArray method.
@heff
Copy link
Member

heff commented May 20, 2014

The PR's looking good so far. Thanks!

shmulik added a commit to shmulik/video.js that referenced this issue May 20, 2014
Using the instanceof Array method will not work for arrays created on another frame,
Instead of instanceof we should use Array.isArray, but this is not supported on IE8.
So vjs.obj.isArray shim was created for the isArray method.
shmulik added a commit to shmulik/video.js that referenced this issue May 20, 2014
Adding test for the vjs.obj.isArray method
shmulik added a commit to shmulik/video.js that referenced this issue May 20, 2014
Added test for the vjs.obj.isArray method.
shmulik added a commit to shmulik/video.js that referenced this issue May 20, 2014
Added test for the vgs.obj.isArray
@heff heff closed this as completed in 6d78c95 Jun 12, 2014
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants