mirror of
https://github.com/videojs/video.js.git
synced 2025-01-10 23:30:03 +02:00
This commit is contained in:
parent
6116e3c3da
commit
6d78c95bb4
@ -2,7 +2,7 @@ CHANGELOG
|
||||
=========
|
||||
|
||||
## HEAD (Unreleased)
|
||||
_(none)_
|
||||
* Added cross-browser isArray for cross-frame support. fixes #1195 ([view](https://github.com/videojs/video.js/pull/1218))
|
||||
|
||||
--------------------
|
||||
|
||||
|
@ -471,7 +471,7 @@ vjs.Component.prototype.initChildren = function(){
|
||||
|
||||
if (children) {
|
||||
// Allow for an array of children details to passed in the options
|
||||
if (children instanceof Array) {
|
||||
if (vjs.obj.isArray(children)) {
|
||||
for (var i = 0; i < children.length; i++) {
|
||||
child = children[i];
|
||||
|
||||
|
@ -160,6 +160,17 @@ vjs.obj.isPlain = function(obj){
|
||||
&& obj.constructor === Object;
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if an object is Array
|
||||
* Since instanceof Array will not work on arrays created in another frame we need to use Array.isArray, but since IE8 does not support Array.isArray we need this shim
|
||||
* @param {Object} obj Object to check
|
||||
* @return {Boolean} True if plain, false otherwise
|
||||
* @private
|
||||
*/
|
||||
vjs.obj.isArray = Array.isArray || function(arr) {
|
||||
return Object.prototype.toString.call(arr) === '[object Array]';
|
||||
};
|
||||
|
||||
/**
|
||||
* Bind (a.k.a proxy or Context). A simple method for changing the context of a function
|
||||
It also stores a unique id on the function so it can be easily removed from events
|
||||
|
@ -1103,7 +1103,7 @@ vjs.Player.prototype.src = function(source){
|
||||
}
|
||||
|
||||
// Case: Array of source objects to choose from and pick the best to play
|
||||
if (source instanceof Array) {
|
||||
if (vjs.obj.isArray(source)) {
|
||||
|
||||
var sourceTech = this.selectSource(source),
|
||||
techName;
|
||||
|
@ -41,6 +41,14 @@ test('should copy an object', function(){
|
||||
deepEqual(asdf,fdsa);
|
||||
});
|
||||
|
||||
test('should check if an object is an Array', function(){
|
||||
var arr = ['a', 'b', 'c'];
|
||||
ok(vjs.obj.isArray(arr) === true, 'Arr object is an Array');
|
||||
|
||||
var obj = {};
|
||||
ok(vjs.obj.isArray(obj) === false, 'Obj is not an Array');
|
||||
});
|
||||
|
||||
test('should check if an object is plain', function(){
|
||||
var empty = {};
|
||||
ok(vjs.obj.isPlain(empty) === true, 'Empty object is plain');
|
||||
|
Loading…
Reference in New Issue
Block a user