8e25f55430db78d928fd301d54732a388d01f59d
[platform/framework/web/crosswalk-tizen.git] /
1 var baseCopy = require('./baseCopy'),
2     getSymbols = require('./getSymbols'),
3     isNative = require('../lang/isNative'),
4     keys = require('../object/keys');
5
6 /** Native method references. */
7 var preventExtensions = isNative(Object.preventExtensions = Object.preventExtensions) && preventExtensions;
8
9 /** Used as `baseAssign`. */
10 var nativeAssign = (function() {
11   // Avoid `Object.assign` in Firefox 34-37 which have an early implementation
12   // with a now defunct try/catch behavior. See https://bugzilla.mozilla.org/show_bug.cgi?id=1103344
13   // for more details.
14   //
15   // Use `Object.preventExtensions` on a plain object instead of simply using
16   // `Object('x')` because Chrome and IE fail to throw an error when attempting
17   // to assign values to readonly indexes of strings in strict mode.
18   var object = { '1': 0 },
19       func = preventExtensions && isNative(func = Object.assign) && func;
20
21   try { func(preventExtensions(object), 'xo'); } catch(e) {}
22   return !object[1] && func;
23 }());
24
25 /**
26  * The base implementation of `_.assign` without support for argument juggling,
27  * multiple sources, and `customizer` functions.
28  *
29  * @private
30  * @param {Object} object The destination object.
31  * @param {Object} source The source object.
32  * @returns {Object} Returns `object`.
33  */
34 var baseAssign = nativeAssign || function(object, source) {
35   return source == null
36     ? object
37     : baseCopy(source, getSymbols(source), baseCopy(source, keys(source), object));
38 };
39
40 module.exports = baseAssign;