Skip to content

Commit

Permalink
removing view.make
Browse files Browse the repository at this point in the history
  • Loading branch information
tgriesser committed Dec 28, 2012
1 parent d63fe9e commit c1e62cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 29 deletions.
15 changes: 2 additions & 13 deletions backbone.js
Expand Up @@ -1272,18 +1272,6 @@
return this;
},

// For small amounts of DOM Elements, where a full-blown template isn't
// needed, use **make** to manufacture elements, one at a time.
//
// var el = this.make('li', {'class': 'row'}, this.model.escape('title'));
//
make: function(tagName, attributes, content) {
var $el = Backbone.$('<' + tagName + '>');
if (attributes) $el.attr(attributes);
if (content != null) $el.html(content);
return $el[0];
},

// Change the view's element (`this.el` property), including event
// re-delegation.
setElement: function(element, delegate) {
Expand Down Expand Up @@ -1353,7 +1341,8 @@
var attrs = _.extend({}, _.result(this, 'attributes'));
if (this.id) attrs.id = _.result(this, 'id');
if (this.className) attrs['class'] = _.result(this, 'className');
this.setElement(this.make(_.result(this, 'tagName'), attrs), false);
var $el = Backbone.$('<' + _.result(this, 'tagName') + '>').attr(attrs);
this.setElement($el, false);
} else {
this.setElement(_.result(this, 'el'), false);
}
Expand Down
16 changes: 0 additions & 16 deletions test/view.js
Expand Up @@ -29,22 +29,6 @@ $(document).ready(function() {
strictEqual(view.$('a b').html(), 'test');
});

test("make", 3, function() {
var div = view.make('div', {id: 'test-div'}, "one two three");

equal(div.tagName.toLowerCase(), 'div');
equal(div.id, 'test-div');
equal($(div).text(), 'one two three');
});

test("make can take falsy values for content", 2, function() {
var div = view.make('div', {id: 'test-div'}, 0);
equal($(div).text(), '0');

div = view.make('div', {id: 'test-div'}, '');
equal($(div).text(), '');
});

test("initialize", 1, function() {
var View = Backbone.View.extend({
initialize: function() {
Expand Down

0 comments on commit c1e62cd

Please sign in to comment.