Commit 067d0cd0 067d0cd01596e68dd98f427c0c9e7ec6da46dffc by Nicolas Perriault

Merge pull request #746 from laurentj/fix-mergeobjects

Fix mergeobjects
2 parents efefe2b0 ec2bbccb
......@@ -634,7 +634,7 @@ function isPlainObject(obj) {
* @param Object opts optional options to be passed in
* @return Object
*/
function mergeObjectsInSlimerjs(origin, add, opts) {
function mergeObjectsInGecko(origin, add, opts) {
"use strict";
var options = opts || {},
......@@ -648,9 +648,20 @@ function mergeObjectsInSlimerjs(origin, add, opts) {
origin[p] = keepReferences ? add[p] : clone(add[p]);
}
} else {
// if a property is only a getter, we could have a Javascript error
// in strict mode "TypeError: setting a property that has only a getter"
// when setting the value to the new object (gecko 25+).
// To avoid it, let's define the property on the new object, do not set
// directly the value
var prop = Object.getOwnPropertyDescriptor(add, p);
if (prop.get && !prop.set) {
Object.defineProperty(origin, p, prop)
}
else {
origin[p] = add[p];
}
}
}
return origin;
}
......@@ -672,7 +683,7 @@ function mergeObjects(origin, add, opts) {
// Because of an issue in the module system of slimerjs (security membranes?)
// constructor is undefined.
// let's use an other algorithm
return mergeObjectsInSlimerjs(origin, add);
return mergeObjectsInGecko(origin, add, options);
}
for (var p in add) {
......