jenkins-bot has submitted this change and it was merged.

Change subject: Make ve.copyArray() / copyObject() work with booleans
......................................................................


Make ve.copyArray() / copyObject() work with booleans

This should really be fixed to not enumerate all types but be nicer.
Timo said he'd do that.

Change-Id: I15807696a7324d3fb207ed41b442a83dc83a75ec
---
M modules/ve/test/ve.test.js
M modules/ve/ve.js
2 files changed, 6 insertions(+), 4 deletions(-)

Approvals:
  Krinkle: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/modules/ve/test/ve.test.js b/modules/ve/test/ve.test.js
index b6fd1f0..cd88cf2 100644
--- a/modules/ve/test/ve.test.js
+++ b/modules/ve/test/ve.test.js
@@ -291,7 +291,7 @@
 } );
 
 QUnit.test( 'copyArray', 6, function ( assert ) {
-       var simpleArray = [ 'foo', 3 ],
+       var simpleArray = [ 'foo', 3, true, false ],
                withObj = [ { 'bar': 'baz', 'quux': 3 }, 5, null ],
                nestedArray = [ [ 'a', 'b' ], [ 1, 3, 4 ] ],
                sparseArray = [ 'a', undefined, undefined, 'b' ],
@@ -337,7 +337,7 @@
 } );
 
 QUnit.test( 'copyObject', 6, function ( assert ) {
-       var simpleObj = { 'foo': 'bar', 'baz': 3, 'quux': null },
+       var simpleObj = { 'foo': 'bar', 'baz': 3, 'quux': null, 'truth': true, 
'falsehood': false },
                nestedObj = { 'foo': { 'bar': 'baz', 'quux': 3 }, 'whee': 5 },
                withArray = { 'foo': [ 'a', 'b' ], 'bar': [ 1, 3, 4 ] },
                withSparseArray = { 'foo': [ 'a', undefined, undefined, 'b' ] },
diff --git a/modules/ve/ve.js b/modules/ve/ve.js
index 1b5732c..94c8dee 100644
--- a/modules/ve/ve.js
+++ b/modules/ve/ve.js
@@ -470,7 +470,8 @@
                for ( i = 0; i < source.length; i++ ) {
                        sourceValue = source[i];
                        sourceType = typeof sourceValue;
-                       if ( sourceType === 'string' || sourceType === 'number' 
|| sourceType === 'undefined' || sourceValue === null ) {
+                       if ( sourceType === 'string' || sourceType === 'number' 
|| sourceType === 'boolean' ||
+                                       sourceType === 'undefined' || 
sourceValue === null ) {
                                destination.push( sourceValue );
                        } else if ( ve.isPlainObject( sourceValue ) ) {
                                destination.push( ve.copyObject( sourceValue ) 
);
@@ -499,7 +500,8 @@
                for ( key in source ) {
                        sourceValue = source[key];
                        sourceType = typeof sourceValue;
-                       if ( sourceType === 'string' || sourceType === 'number' 
|| sourceType === 'undefined' || sourceValue === null ) {
+                       if ( sourceType === 'string' || sourceType === 'number' 
|| sourceType === 'boolean' ||
+                                       sourceType === 'undefined' || 
sourceValue === null ) {
                                destination[key] = sourceValue;
                        } else if ( ve.isPlainObject( sourceValue ) ) {
                                destination[key] = ve.copyObject( sourceValue );

-- 
To view, visit https://gerrit.wikimedia.org/r/50020
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I15807696a7324d3fb207ed41b442a83dc83a75ec
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Catrope <roan.katt...@gmail.com>
Gerrit-Reviewer: Krinkle <ttij...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to