react / react-0.13.3 / examples / basic-commonjs / node_modules / reactify / node_modules / react-tools / src / vendor_deprecated / core / copyProperties.js
81155 views/**1* Copyright 2013-2014, Facebook, Inc.2* All rights reserved.3*4* This source code is licensed under the BSD-style license found in the5* LICENSE file in the root directory of this source tree. An additional grant6* of patent rights can be found in the PATENTS file in the same directory.7*8* @providesModule copyProperties9*/1011/**12* Copy properties from one or more objects (up to 5) into the first object.13* This is a shallow copy. It mutates the first object and also returns it.14*15* NOTE: `arguments` has a very significant performance penalty, which is why16* we don't support unlimited arguments.17*/18function copyProperties(obj, a, b, c, d, e, f) {19obj = obj || {};2021if (__DEV__) {22if (f) {23throw new Error('Too many arguments passed to copyProperties');24}25}2627var args = [a, b, c, d, e];28var ii = 0, v;29while (args[ii]) {30v = args[ii++];31for (var k in v) {32obj[k] = v[k];33}3435// IE ignores toString in object iteration.. See:36// webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html37if (v.hasOwnProperty && v.hasOwnProperty('toString') &&38(typeof v.toString != 'undefined') && (obj.toString !== v.toString)) {39obj.toString = v.toString;40}41}4243return obj;44}4546module.exports = copyProperties;4748// deprecation notice49console.warn(50'react/lib/copyProperties has been deprecated and will be removed in the ' +51'next version of React. All uses can be replaced with ' +52'Object.assign(obj, a, b, ...) or _.extend(obj, a, b, ...).'53);545556