Merge pull request #1129 from r00k/allow-content-of-0-in-make

Allow make to take falsy arguments for content.
This commit is contained in:
brad dunbar
2012-03-21 14:27:10 -07:00
2 changed files with 9 additions and 1 deletions

View File

@@ -1192,7 +1192,7 @@
make: function(tagName, attributes, content) {
var el = document.createElement(tagName);
if (attributes) $(el).attr(attributes);
if (content) $(el).html(content);
if (content != null) $(el).html(content);
return el;
},

View File

@@ -33,6 +33,14 @@ $(document).ready(function() {
equal($(div).text(), 'one two three');
});
test("View: make can take falsy values for content", function() {
var div = view.make('div', {id: 'test-div'}, 0);
equal($(div).text(), '0');
var div = view.make('div', {id: 'test-div'}, '');
equal($(div).text(), '');
});
test("View: initialize", function() {
var View = Backbone.View.extend({
initialize: function() {