mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-28 08:10:35 +00:00
Merge "Fix copyObject/copyArray behavior with null values"
This commit is contained in:
commit
82a15d66fc
|
@ -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' ] },
|
||||
|
|
|
@ -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 );
|
||||
|
|
Loading…
Reference in a new issue