$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;
} );
}
- 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' );
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<</foo>z' );
assert.equal(
'Foo <bar bar="bar">&gt;</bar>',
'Replacement is not considered html'
);
- */
mw.messages.set( 'object-replace', 'Foo $1' );