ee69c3d56d4ba7bb7ec3d08553856af38674201f
[platform/framework/web/crosswalk-tizen.git] /
1 define(['./forOwn', '../lang/isPlainObject'], function (forOwn, isPlainObject) {
2
3     /**
4      * Deeply copy missing properties in the target from the defaults.
5      */
6     function deepFillIn(target, defaults){
7         var i = 0,
8             n = arguments.length,
9             obj;
10
11         while(++i < n) {
12             obj = arguments[i];
13             if (obj) {
14                 // jshint loopfunc: true
15                 forOwn(obj, function(newValue, key) {
16                     var curValue = target[key];
17                     if (curValue == null) {
18                         target[key] = newValue;
19                     } else if (isPlainObject(curValue) &&
20                                isPlainObject(newValue)) {
21                         deepFillIn(curValue, newValue);
22                     }
23                 });
24             }
25         }
26
27         return target;
28     }
29
30     return deepFillIn;
31
32 });