mirror of
https://github.com/jashkenas/backbone.git
synced 2026-04-30 03:00:06 -04:00
Merge pull request #1234 from braddunbar/tagname
Fix #1228 - tagName can be provided as a function.
This commit is contained in:
@@ -1268,7 +1268,7 @@
|
||||
var attrs = _.extend({}, getValue(this, 'attributes'));
|
||||
if (this.id) attrs.id = this.id;
|
||||
if (this.className) attrs['class'] = this.className;
|
||||
this.setElement(this.make(this.tagName, attrs), false);
|
||||
this.setElement(this.make(getValue(this, 'tagName'), attrs), false);
|
||||
} else {
|
||||
this.setElement(this.el, false);
|
||||
}
|
||||
|
||||
@@ -217,8 +217,13 @@ $(document).ready(function() {
|
||||
test("Clone attributes object", function() {
|
||||
var View = Backbone.View.extend({attributes: {foo: 'bar'}});
|
||||
var v1 = new View({id: 'foo'});
|
||||
ok(v1.el.id === 'foo');
|
||||
strictEqual(v1.el.id, 'foo');
|
||||
var v2 = new View();
|
||||
ok(!v2.el.id);
|
||||
});
|
||||
|
||||
test("#1228 - tagName can be provided as a function", function() {
|
||||
var View = Backbone.View.extend({tagName: function(){ return 'p'; }});
|
||||
ok(new View().$el.is('p'));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user