mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
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:
@@ -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;
|
||||
},
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user