rtfeldman/seamless-immutable

isMergableObject returns true for an empty object

Ouverte

#82 ouverte le 28 déc. 2015

 (1 commentaire) (0 réaction) (0 personne assignée)JavaScript (221 forks)batch import
bughelp wanted

Métriques du dépôt

Stars
 (5 367 étoiles)
Métriques de merge PR
 (Métriques PR en attente)

Description

      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.

Guide contributeur