Fix jqueryMsg breaking when passed an undefined param
authorJakob Warkotsch <j.warkotsch@gmail.com>
Thu, 18 Oct 2018 16:02:12 +0000 (18:02 +0200)
committerJakob Warkotsch <j.warkotsch@gmail.com>
Thu, 18 Oct 2018 16:43:40 +0000 (18:43 +0200)
This restores the behavior for undefined params as it was before
I445f9194bb8b2ed35baafbda30d1d0d008b64e2c

Bug: T207397
Change-Id: I751f01a9b3cd8bb87d7d7def98c918a87ddf81cd

resources/src/mediawiki.jqueryMsg/mediawiki.jqueryMsg.js
tests/qunit/suites/resources/mediawiki/mediawiki.jqueryMsg.test.js

index 8b348c8..082db5c 100644 (file)
                                !/\{\{|[<>[&]/.test( this.map.get( this.key ) ) &&
                                // jqueryMsg parser is needed when jQuery objects or DOM nodes are passed in as parameters
                                !this.parameters.some( function ( param ) {
-                                       return param instanceof $ || param.nodeType !== undefined;
+                                       return param instanceof $ || ( param && param.nodeType !== undefined );
                                } )
                        )
                ) {
index 405a60f..913022d 100644 (file)
                        'Passing a DOM node as a parameter to a message without wikitext works correctly'
                );
 
+               assert.strictEqual(
+                       mw.message( 'param-test', undefined ).parse(),
+                       'Hello $1',
+                       'Passing undefined as a parameter to a message does not throw an exception'
+               );
+
                assert.strictEqual(
                        mw.message(
                                'param-test-with-link',