Merge "Fix copyObject/copyArray behavior with null values"

This commit is contained in:
Trevor Parscal 2012-10-30 16:59:02 +00:00 committed by Gerrit Code Review
commit 82a15d66fc
2 changed files with 4 additions and 4 deletions

View file

@ -292,7 +292,7 @@ QUnit.test( 'getObjectValues', 6, function ( assert ) {
QUnit.test( 'copyArray', 6, function ( assert ) {
var simpleArray = [ 'foo', 3 ],
withObj = [ { 'bar': 'baz', 'quux': 3 }, 5 ],
withObj = [ { 'bar': 'baz', 'quux': 3 }, 5, null ],
nestedArray = [ [ 'a', 'b' ], [ 1, 3, 4 ] ],
sparseArray = [ 'a', undefined, undefined, 'b' ],
withSparseArray = [ [ 'a', undefined, undefined, 'b' ] ],
@ -337,7 +337,7 @@ QUnit.test( 'copyArray', 6, function ( assert ) {
} );
QUnit.test( 'copyObject', 6, function ( assert ) {
var simpleObj = { 'foo': 'bar', 'baz': 3 },
var simpleObj = { 'foo': 'bar', 'baz': 3, 'quux': null },
nestedObj = { 'foo': { 'bar': 'baz', 'quux': 3 }, 'whee': 5 },
withArray = { 'foo': [ 'a', 'b' ], 'bar': [ 1, 3, 4 ] },
withSparseArray = { 'foo': [ 'a', undefined, undefined, 'b' ] },

View file

@ -459,7 +459,7 @@
for ( i = 0; i < source.length; i++ ) {
sourceValue = source[i];
sourceType = typeof sourceValue;
if ( sourceType === 'string' || sourceType === 'number' || sourceType === 'undefined' ) {
if ( sourceType === 'string' || sourceType === 'number' || sourceType === 'undefined' || sourceValue === null ) {
destination.push( sourceValue );
} else if ( ve.isPlainObject( sourceValue ) ) {
destination.push( ve.copyObject( sourceValue ) );
@ -489,7 +489,7 @@
for ( key in source ) {
sourceValue = source[key];
sourceType = typeof sourceValue;
if ( sourceType === 'string' || sourceType === 'number' || sourceType === 'undefined' ) {
if ( sourceType === 'string' || sourceType === 'number' || sourceType === 'undefined' || sourceValue === null ) {
destination[key] = sourceValue;
} else if ( ve.isPlainObject( sourceValue ) ) {
destination[key] = ve.copyObject( sourceValue );