From 51387ebc363bb8a7e2974941e97083a8bad5bdc3 Mon Sep 17 00:00:00 2001 From: Genadi Samokovarov Date: Thu, 2 Aug 2012 01:18:46 +0300 Subject: [PATCH 1/4] getValue for View::className and View::id --- backbone.js | 4 ++-- test/view.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/backbone.js b/backbone.js index f401b08c..f0812fd3 100644 --- a/backbone.js +++ b/backbone.js @@ -1290,8 +1290,8 @@ _ensureElement: function() { if (!this.el) { var attrs = _.extend({}, getValue(this, 'attributes')); - if (this.id) attrs.id = this.id; - if (this.className) attrs['class'] = this.className; + if (this.id) attrs.id = getValue(this, 'id'); + if (this.className) attrs['class'] = getValue(this, 'className'); this.setElement(this.make(getValue(this, 'tagName'), attrs), false); } else { this.setElement(this.el, false); diff --git a/test/view.js b/test/view.js index a4da11ae..fcc06c42 100644 --- a/test/view.js +++ b/test/view.js @@ -135,6 +135,19 @@ $(document).ready(function() { ok(!view.el); }); + test("View: with className and id functions", 2, function() { + var viewClass = Backbone.View.extend({ + className: function() { + return 'one'; + }, + id: function() { + return 'two'; + } + }); + equal((new viewClass).el.className, 'one'); + equal((new viewClass).el.id, 'two'); + }); + test("View: with attributes", 2, function() { var view = new Backbone.View({attributes : {'class': 'one', id: 'two'}}); equal(view.el.className, 'one'); From 281014319da3e5a1748416afa5bf5607313fafd2 Mon Sep 17 00:00:00 2001 From: Brad Dunbar Date: Wed, 8 Aug 2012 11:40:54 -0400 Subject: [PATCH 2/4] Tweak id/className test. --- test/view.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/test/view.js b/test/view.js index fcc06c42..88490804 100644 --- a/test/view.js +++ b/test/view.js @@ -136,16 +136,17 @@ $(document).ready(function() { }); test("View: with className and id functions", 2, function() { - var viewClass = Backbone.View.extend({ + var View = Backbone.View.extend({ className: function() { - return 'one'; + return 'className'; }, id: function() { - return 'two'; + return 'id'; } }); - equal((new viewClass).el.className, 'one'); - equal((new viewClass).el.id, 'two'); + var view = new View(); + strictEqual(view.el.className, 'className'); + strictEqual(view.el.id, 'id'); }); test("View: with attributes", 2, function() { From 71d0fe3dccffc01f7badba5af4b2cae1c5af1aa8 Mon Sep 17 00:00:00 2001 From: Ted Han Date: Tue, 14 Aug 2012 00:31:41 -0500 Subject: [PATCH 3/4] escape todo items. --- examples/todos/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/todos/index.html b/examples/todos/index.html index e964fe16..46952fd2 100644 --- a/examples/todos/index.html +++ b/examples/todos/index.html @@ -52,7 +52,7 @@