Reverting temporary change Iedb304f8 as promised
authorKaldari <rkaldari@wikimedia.org>
Wed, 6 Mar 2013 01:07:25 +0000 (17:07 -0800)
committerKaldari <rkaldari@wikimedia.org>
Wed, 6 Mar 2013 01:12:34 +0000 (17:12 -0800)
Change-Id: Id2d0e2242cfb3fe84b68c5bfb8ab7c74fdf92f7d

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

index 76f0259..183b525 100644 (file)
                                                $span.append( childNode );
                                        } );
                                } else {
-                                       // strings, integers, anything else
-                                       // (will soon switch to createTextNode() for non-objects)
-                                       $span.append( node );
+                                       // Let jQuery append nodes, arrays of nodes and jQuery objects
+                                       // other things (strings, numbers, ..) are appended as text nodes (not as HTML strings)
+                                       $span.append( $.type( node ) === 'object' ? node : document.createTextNode( node ) );
                                }
                        } );
                        return $span;
index f23964c..0a9df96 100644 (file)
@@ -81,7 +81,7 @@
                        } );
        }
 
-       QUnit.test( 'Replace', 7, function ( assert ) {
+       QUnit.test( 'Replace', 9, function ( assert ) {
                var parser = mw.jqueryMsg.getMessageFunction();
 
                mw.messages.set( 'simple', 'Foo $1 baz $2' );
@@ -90,7 +90,6 @@
                assert.equal( parser( 'simple', 'bar' ), 'Foo bar baz $2', 'Replacements with less substitutes' );
                assert.equal( parser( 'simple', 'bar', 'quux' ), 'Foo bar baz quux', 'Replacements with all substitutes' );
 
-               /* Temporarily disabling until 2013-03 --Kaldari
                mw.messages.set( 'plain-input', '<foo foo="foo">x$1y&lt;</foo>z' );
 
                assert.equal(
                        'Foo &lt;bar bar="bar"&gt;&amp;gt;&lt;/bar&gt;',
                        'Replacement is not considered html'
                );
-               */
 
                mw.messages.set( 'object-replace', 'Foo $1' );