Subramanya Sastry has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/51275


Change subject: Fix type of tokens passed to cb's to ensure they are arrays.
......................................................................

Fix type of tokens passed to cb's to ensure they are arrays.

* Local RT testing emitted warnings about non-array tokens being
  received from parser functions code.

* Fixed up a few sites that were the source of warnings.

* No change in parser test results.

Change-Id: I74dcb68dc4fba2ee0582769b400afb9434cbc8c9
---
M js/lib/ext.core.ParserFunctions.js
1 file changed, 6 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Parsoid 
refs/changes/75/51275/1

diff --git a/js/lib/ext.core.ParserFunctions.js 
b/js/lib/ext.core.ParserFunctions.js
index 0c27de4..55d3145 100644
--- a/js/lib/ext.core.ParserFunctions.js
+++ b/js/lib/ext.core.ParserFunctions.js
@@ -33,7 +33,7 @@
        } else if (k.constructor === Array && k.length > 0) {
                return k.concat( ['='], v );
        } else {
-               return trim ? Util.tokenTrim(v) : v;
+               return trim ? (v.constructor === String ? v.trim() : 
Util.tokenTrim(v)) : v;
        }
 };
 
@@ -54,7 +54,7 @@
                if ( kv.k ) {
                        cb( { tokens: [kv.k + '=' + kv.v] } );
                } else {
-                       cb( { tokens: trim ? Util.tokenTrim([kv.v]) : [kv.v] } 
);
+                       cb( { tokens: [trim ? kv.v.trim() : kv.v] } );
                }
        } else {
                var self = this,
@@ -217,7 +217,7 @@
                        cb ( {} );
                }
        } else if ( v ) {
-               cb( { tokens: v } );
+               cb( { tokens: v.constructor === Array ? v : [v] } );
        } else {
                // nothing found at all.
                cb( {} );
@@ -236,7 +236,9 @@
                this.env.dp( 'switch found: ', target, dict, ' res=', 
dict[target] );
                dict[target].get({
                        type: 'tokens/x-mediawiki/expanded',
-                       cb: function( res ) { cb ( { tokens: 
Util.tokenTrim(res) } ); },
+                       cb: function( res ) {
+                               cb ( { tokens: res.constructor === String ? 
[res.trim()] : Util.tokenTrim(res) } );
+                       },
                        asyncCB: cb
                });
        } else {

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I74dcb68dc4fba2ee0582769b400afb9434cbc8c9
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Parsoid
Gerrit-Branch: master
Gerrit-Owner: Subramanya Sastry <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to