Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
John McEleney
/
casperjs
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit
067d0cd0
...
067d0cd01596e68dd98f427c0c9e7ec6da46dffc
authored
2013-12-05 01:33:22 -0800
by
Nicolas Perriault
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge pull request #746 from laurentj/fix-mergeobjects
Fix mergeobjects
2 parents
efefe2b0
ec2bbccb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
3 deletions
modules/utils.js
modules/utils.js
View file @
067d0cd
...
...
@@ -634,7 +634,7 @@ function isPlainObject(obj) {
* @param Object opts optional options to be passed in
* @return Object
*/
function
mergeObjectsIn
Slimerjs
(
origin
,
add
,
opts
)
{
function
mergeObjectsIn
Gecko
(
origin
,
add
,
opts
)
{
"use strict"
;
var
options
=
opts
||
{},
...
...
@@ -648,7 +648,18 @@ function mergeObjectsInSlimerjs(origin, add, opts) {
origin
[
p
]
=
keepReferences
?
add
[
p
]
:
clone
(
add
[
p
]);
}
}
else
{
origin
[
p
]
=
add
[
p
];
// 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
mergeObjectsIn
Slimerjs
(
origin
,
add
);
return
mergeObjectsIn
Gecko
(
origin
,
add
,
options
);
}
for
(
var
p
in
add
)
{
...
...
Please
register
or
sign in
to post a comment