rtfeldman/seamless-immutable

isMergableObject returns true for an empty object

开放

#82 创建于 2015年12月28日

 (1 条评论) (0 个反应) (0 位负责人)JavaScript (221 个派生)batch import
bughelp wanted

仓库指标

星标
 (5,367 个星标)
PR 合并指标
 (PR 指标待抓取)

描述

      function addToResult(currentObj, otherObj, key) {
      var immutableValue = Immutable(otherObj[key]);
      var mergerResult = merger && merger(currentObj[key], immutableValue, config);
      var currentValue = currentObj[key];

      console.log("IS NEW OBJECT MERGABLE", isMergableObject(new Object()));

  -> seamless-immutable.js:306 IS NEW OBJECT MERGABLE true

In my production build currentValue is sometimes an empty object, and with deep merge enabled we error out when trying to call merge() on said object. In dev mode this never seems to happen.

I've worked around this with an additional check to isMergableObject which checks that Object.keys(target).length > 0. If this seems like an acceptable fix I'd love to submit a PR.

贡献者指南