[Pkg-javascript-commits] [backbone] 50/211: Model::escape() now coerces non-string (non-falsy) values to strings before escaping them.

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 17:00:01 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.0
in repository backbone.

commit 289d4e0066570659792591220cfcaf5458153b73
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Tue Jan 11 12:58:15 2011 -0500

    Model::escape() now coerces non-string (non-falsy) values to strings before escaping them.
---
 backbone.js   | 2 +-
 test/model.js | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/backbone.js b/backbone.js
index 356405b..022bf6b 100644
--- a/backbone.js
+++ b/backbone.js
@@ -160,7 +160,7 @@
       var html;
       if (html = this._escapedAttributes[attr]) return html;
       var val = this.attributes[attr];
-      return this._escapedAttributes[attr] = escapeHTML(val == null ? '' : val);
+      return this._escapedAttributes[attr] = escapeHTML(val == null ? '' : '' + val);
     },
 
     // Returns `true` if the attribute contains a value that is not null
diff --git a/test/model.js b/test/model.js
index 5a313dc..c08e9a2 100644
--- a/test/model.js
+++ b/test/model.js
@@ -110,6 +110,8 @@ $(document).ready(function() {
     equals(doc.escape('audience'), 'Bill & Bob');
     doc.set({audience: 'Tim > Joan'});
     equals(doc.escape('audience'), 'Tim > Joan');
+    doc.set({audience: 10101});
+    equals(doc.escape('audience'), '10101');
     doc.unset('audience');
     equals(doc.escape('audience'), '');
   });

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list