Fixed keywords interactions when cloning a slide.
Fixed object cloning function to support arrays.namespaces
parent
b47f1bbcd8
commit
9dcb4c5951
10
js/h5p.js
10
js/h5p.js
|
@ -275,21 +275,21 @@ H5P.playVideo = function ($target, params, skipButtonText, cp, onEnded) {
|
||||||
* @param {type} recursive
|
* @param {type} recursive
|
||||||
* @returns {object} A clone of object.
|
* @returns {object} A clone of object.
|
||||||
*/
|
*/
|
||||||
H5P.cloneObject = function (object, recursive) {
|
H5P.cloneObject = function (object, recursive, array) {
|
||||||
var clone = {};
|
var clone = array !== undefined && array ? [] : {};
|
||||||
|
|
||||||
for (var i in object) {
|
for (var i in object) {
|
||||||
if (object.hasOwnProperty(i)) {
|
if (object.hasOwnProperty(i)) {
|
||||||
if (recursive !== undefined && recursive && typeof object[i] === 'object') {
|
if (recursive !== undefined && recursive && typeof object[i] === 'object') {
|
||||||
clone[i] = object[i] instanceof Array ? object[i].slice() : H5P.cloneObject(object[i], recursive);
|
clone[i] = H5P.cloneObject(object[i], recursive, object[i] instanceof Array);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
clone[i] = object[i];
|
clone[i] = object[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
};
|
};
|
||||||
|
|
||||||
// We have several situations where we want to shuffle an array, extend array
|
// We have several situations where we want to shuffle an array, extend array
|
||||||
|
|
Loading…
Reference in New Issue