Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Preventing arrays from ending up with undefined values where the inde…

…x should have been deleted.
  • Loading branch information...
commit bcfe79eea4d34195b25a76378e70d1da290a692b 1 parent 08c0cb8
Jon Ramsey leinster authored

Showing 2 changed files with 7 additions and 2 deletions. Show diff stats Hide diff stats

  1. +5 1 src/jsondiffpatch.js
  2. +2 1  test/test.js
6 src/jsondiffpatch.js
@@ -276,7 +276,11 @@
276 276 return;
277 277 }
278 278 if (typeof value == 'undefined') {
279   - delete obj[key];
  279 + if (obj instanceof Array) {
  280 + obj.splice(key, 1);
  281 + } else {
  282 + delete obj[key];
  283 + }
280 284 }
281 285 else {
282 286 obj[key] = value;
3  test/test.js
@@ -160,7 +160,7 @@ test("change from/to null", 1, function(){
160 160 equal(typeof this.delta2, "undefined", 'original equals new');
161 161 });
162 162
163   -test("change simple list", 1, function(){
  163 +test("change simple list", 2, function(){
164 164
165 165 this.makeCopy();
166 166
@@ -171,6 +171,7 @@ test("change simple list", 1, function(){
171 171
172 172 this.diffPatch();
173 173
  174 + deepEqual(this.sa.languages, this.sa2.languages);
174 175 equal(typeof this.delta2, "undefined", 'original equals new');
175 176 });
176 177

0 comments on commit bcfe79e

Please sign in to comment.
Something went wrong with that request. Please try again.