Skip to content

Commit

Permalink
relying on _.escape, and fixing a lint problem.
Browse files Browse the repository at this point in the history
  • Loading branch information
jashkenas committed Oct 31, 2011
1 parent 18be710 commit 3392d5f
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions backbone.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if (!callback) {
calls[ev] = {};
} else if (node = calls[ev]) {
while (prev = node, node = node.next) {
while ((prev = node) && (node = node.next)) {
if (node.callback !== callback) continue;
prev.next = node.next;
node.context = node.callback = null;
Expand Down Expand Up @@ -170,7 +170,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] = _.escape(val == null ? '' : '' + val);
},

// Returns `true` if the attribute contains a value that is not null
Expand Down Expand Up @@ -1160,9 +1160,4 @@
};
};

// Helper function to escape a string for HTML rendering.
var escapeHTML = function(string) {
return string.replace(/&(?!\w+;|#\d+;|#x[\da-f]+;)/gi, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;').replace(/'/g, '&#x27;').replace(/\//g,'&#x2F;');
};

}).call(this);

0 comments on commit 3392d5f

Please sign in to comment.